git 解决 “fatal: Could not read from remote repository.“

这篇具有很好参考价值的文章主要介绍了git 解决 “fatal: Could not read from remote repository.“。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

现象

在使用Git将本地仓库推送到远程仓库的时候,发生了如下错误:“fatal: Could not read from remote repository.”

git 解决 “fatal: Could not read from remote repository.“

 原因

出现这错误一般是以下两种原因:

  • 客户端与服务端未生成 ssh key
  • 客户端与服务端的ssh key不匹配

为解决以上问题,我们需要重新生成一次ssh key ,并重新配置一下GitHub账户即可。

解决方法

1. 生成新的SSH key
   如果是客户端与服务端未生成ssh key,那么直接使用:ssh-keygen -t rsa -C "youremail@example.com" 生成新的rsa密钥即可。
   如果是客户端与服务端的ssh key 不匹配,此时需要先将本地生成的 id_rsa以及id_rsa.pub这两个文件【一般在用户名下的.ssh文件夹下】删除掉,然后再使用上述指令生成新的rsa密钥。

git 解决 “fatal: Could not read from remote repository.“

 

补充ssh-keygen -t rsa -b 4096 -C "邮箱":这条命令的目的是为了让本地机器ssh登录远程机器上的GitHub账户无需输入密码。

ssh-keygen(基于密匙的安全验证):需要依靠密钥进行安全验证,必须为自己创建一对密钥,并把公用密钥放在需要访问的服务器上。
	-t 即指定密钥的类型。密钥的类型有两种,一种是RSA,一种是DSA。
	-b 指定密钥长度。对于RSA密钥,最小要求768位,默认是2048位。命令中的4096指的是RSA密钥长度为4096位。DSA密钥必须恰好是1024位(FIPS 186-2 标准的要求)。
	-C 表示要提供一个新注释,用于识别这个密钥。“”里面不一定非要填邮箱,可以是任何内容,邮箱仅仅是识别用的key。

2. 将SSH key 添加到 ssh-agent

   使用 ssh-add ~/.ssh/id_rsa 将产生的新ssh key添加到ssh-agent中:

git 解决 “fatal: Could not read from remote repository.“

 补充: 如果出现“Could not open a connection to your authentication agent.”的错误可以使用以下两种方式解决:

eval "$(ssh-agent -s)"

或者:

eval `ssh-agent`

3. 将SSH key 添加到你的GitHub账户

  在账户选项中选择 “Settings”–>“SSH and GPG keys”–>“New SSH key”,然后打开之前新生成的id_rsa.pub文件,将密钥复制后填写到账户中。

4. 验证key

git 解决 “fatal: Could not read from remote repository.“

 

当出现上述界面时说明配置成功,此时可以再次执行git push 操作将本地仓库推送到远程。

注: 以上操作命令均在 Git Bash 中完成。文章来源地址https://www.toymoban.com/news/detail-493498.html

到了这里,关于git 解决 “fatal: Could not read from remote repository.“的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • git报错:Permission denied (publickey). fatal: Could not read from remote repository.

    背景 :由于新换了电脑,新装了git,所以在用git拉取代码的时候就出现了标题一样的错误 ternimal下出现下面错误: Permissiondenied (publickey). fatal:Could not read from remote repository. Pleasemake sure you have the correct access rights and the repository exists. 分析原因 : 原因是由于你在本地(或者服务

    2024年02月05日
    浏览(47)
  • Git 报错:Connection closed by remote host. fatal: Could not read from remote repository.

    1、背景: 今天部署到GitHub时,出现此错误。昨天还正常,今天突然这样。 2、详细错误信息: 3、解析错误信息: 错误信息翻译成中文后: 通过以上可知: 系统连接不到GitHub,因此无法用SSH密钥进行识别。 ---- 说明是网络问题。 4、实践探索 - 解决过程: 出现错误的时候,

    2024年02月07日
    浏览(94)
  • [git]报错fatal: ‘origin‘ does not appear to be a git repository Could not read from remote repository

    问题1:   fatal: \\\'origin\\\' does not appear to be a git repository fatal: Could not read from remote repository. 说明库是有的,但是没办法push。所以重新关联一下。 解决方法: 输入以下代码, 这是因为本地的分支没有和远程分支建立联系,需要执行以下代码就可以正常 push 了   问题2:   fatal:

    2024年02月09日
    浏览(43)
  • git问题:git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.

    重装系统后,git push项目时出现git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.Please make sure you have the correct access rights and the repository exists.出现这个问题表示你在尝试将本地代码推送到GitHub时,没有提供正确的公钥,或者你的公钥没有被添加到你的GitHu

    2024年02月21日
    浏览(44)
  • git pull 报错 could not read from remote repository解决

    git pull 报错 remote: Your account has been blocked. fatal: could not read from remote repository。一般是SSH的形式clone的仓库,权限被更改了。 如下步骤解决: 重新 生成 gitLabKey 并应用:                  step 1:     使用命令 ssh-keygen -t rsa -b 2048 -C \\\"lvl@svtc.com\\\"                  step 2:     出现

    2024年02月16日
    浏览(30)
  • Permission denied (publickey). fatal: Could not read from remote repository.

    将本地代码推送到远程分支报错:Permission denied (publickey). fatal: Could not read from remote repository. 确保已经添加了正确的 SSH 密钥。可以使用以下命令检查 SSH 密钥是否已经添加: 如果看到消息 “Hi [username]! You\\\'ve successfully authenticated, but GitHub does not provide shell access.” ,则表示已成

    2023年04月18日
    浏览(32)
  • 解决git@github.com: Permission denied (publickey). Could not read from remote repository

    原因分析 Permission denied (publickey) 没有权限的publickey ,出现这错误一般是以下两种原因 客户端与服务端未生成 ssh key 客户端与服务端的ssh key不匹配 找到问题的原因了,解决办法也就有了,重新生成一次ssh key ,服务端也重新配置一次即可。 客户端生成ssh key 470812087@qq.com改为

    2024年02月04日
    浏览(56)
  • IDEA Git 报错could not read from remote repository

    Git:could not read from remote repository。 首先再git后台,检查是否有对应工程的权限 1  检查idea工程project目录下的.git文件夹下的.config文件,origin配置是否正确 打开.config文件,url有两种方式:https的方式、ssh的方式, 检查对应的url是否正确 2 如果正确,请配置ssh 密钥,网上随便

    2024年02月08日
    浏览(36)
  • 解决git@github.com:Permission denied (publickey). Could not read from remote repository. Please make s

    这个错误通常表示没有正确的权限来访问该 Git 仓库。 为了解决GitHub上的权限问题,需要执行以下步骤: 打开命令行终端(例如Git Bash)并输入以下命令: 将公钥添加到GitHub帐户中, 执行以下步骤: 在“Title”字段中为新密钥提供一个描述性标题。 将“Key”字段中的公钥粘

    2024年02月06日
    浏览(42)
  • 【已解决】git clone 报错:Could not read from remote repository. Please make sure you have the correct acce

    换电脑了,克隆代码遇到报错: 找到本地公钥,复制到添加 SSH 公钥处,遇到报错: 官方提出的解决办法:添加 SSH Keys 报已存在怎么办? 按照官方的提示,大概率是原因1,只能重新生成了 但是现在本地这个 SSH Key 在其他地方有使用(Gitee/Github/…),想要保留,再生成一个。

    2024年02月10日
    浏览(41)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包