Git:致命错误:无法从远程仓库读取

623

我想要使用http://danielmiessler.com/study/git/#website来管理我的网站,现在正尝试设置git。

按照指示,我已经完成了最后一步:git push website +master:refs/heads/master。

我在win7中使用git ming32命令行进行工作。

$ git push website +master:refs/heads/master
Bill@***.com's password:
Connection closed by 198.91.80.3
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

这里可能存在一个问题,即程序正在寻找Bill@***.com。当我通过ssh连接到我的站点时,我的用户名不同(假设为“abc”)。因此,也许应该是abc@***.com。如果是这样的话,我不知道如何更改,或者是否可以使用别名推送。


2
我曾经遇到过同样的问题,有时候出现这个错误是因为git服务器无法访问或者出现了“内部服务器错误”之类的问题。 - Morteza
6
请先查看.git/config文件,确保一切都是正确的。对我来说,它的set-url和origin值是错误的。 - mixdev
在我的情况下,我不得不关闭我的WiFi并重新打开它。其他互联网服务都可以使用,包括fast.com,但由于某种原因,GitHub的操作无法正常工作。 - Joshua Pinter
这篇文章提供了很多答案。对于我同时使用工作和个人Git帐户的SSH问题,这篇文章解决了我的问题。https://www.freecodecamp.org/news/manage-multiple-github-accounts-the-ssh-way-2dadc30ccaca/ - Stephane
在我的情况下,我输入了错误的远程URL。该错误与SSH身份验证失败无法区分。 - John Jiang
显示剩余8条评论
62个回答

1
我遇到了这个问题,因为我在中国使用了防火墙... kex_exchange_identification: 远程主机关闭连接致命错误:无法从远程存储库读取。请确保您拥有正确的访问权限并且该存储库存在。

1

我曾经遇到过同样的问题,通过更新到最新的git版本解决了问题。


1

我的解决方案其实很简单。我只需要从这个问题“请键入'yes'、'no'或指纹”中复制并粘贴指纹,而不是仅仅按回车键。


1
在我的情况下,问题及其解决方案就在我面前。当天早些时候,我编辑了/etc/ssh/ssh_config文件并添加了一些密钥。错误信息如下:
/etc/ssh/ssh_config: line 52: Bad configuration option: allowusers
/etc/ssh/ssh_config: terminating, 1 bad configuration options
fatal: Could not read from remote repository.

我删除了 allowusers 键和它的值,一切都如预期般工作。


1
有时候你需要使用完整的URL,其中包括ssh://协议:
ssh://git@yourhost:port/path/repo.git

或者使用指定的端口:
ssh://git@yourhost:port/path/repo.git

对我来说,它解决了这个问题。

1

可能是网络问题。

尝试执行 ssh -vvvT git@gitlab.com。如果服务器意外挂起,则可能是不稳定的网络连接。

将以下内容放入您的 ~/.ssh/config 文件中。

IPQoS lowdelay throughput

0
在罕见情况下,您可能会遇到“fatal: Could not read from remote repository”错误,例如:
[user@example.com repo]$ git fetch --all --prune
Fetching origin
exec request failed on channel 0
fatal: Could not read from remote repository.

当Git服务器文件系统已满时。请运行以下命令进行验证:

ssh -v ssh://git@yourhost/path/repo.git

如果服务器像这样回复:
...
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: publickey
debug1: Offering public key: /home/...
SHA256:...
debug1: Server accepts key: /home/...
SHA256:...
Authenticated to linux-git.....com ([xxx.xxx.xx.xx]:xx) using "publickey".
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: filesystem full
...
debug1: Remote: PTY allocation disabled.
PTY allocation request failed on channel 0
shell request failed on channel 0

然后服务器上的磁盘空间就会耗尽。

我知道这个答案可能不会得到很多赞,但为了完整性而添加。

P.S. 也可以使用类似的东西。

GIT_SSH_COMMAND="ssh -v" git pull

诊断问题。


0
在使用 Putty/Pageant 时,请确保您没有忘记将正确的 SSH 密钥添加到 Pageant,否则将出现此错误。 DUH

0
根据我的经验,导致这个问题出现的原因之一是你的网络连接不稳定

0

我在尝试从工作中的git推送代码到我的个人git时遇到了这个错误 - 默认指向工作git。所以我按照以下步骤进行:

  1. 进入我的个人git帐户并使用默认设置创建repo
  2. 在终端上,使用git remote add origin git@github.com:/.git
  3. 使用git push --set-upstream origin master,确保origin是上游,并且下一个提交只能使用git push进行。

由于某种原因,其他方法对我都不起作用。希望这可以帮助那些使用2个或更多git帐户的人。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接