【问题标题】:git push fails - fatal: the remote end hung up unexpectedlygit push 失败 - 致命:远程端意外挂断
【发布时间】:2021-08-02 06:39:54
【问题描述】:

我在本地创建了一个 git repo。当我尝试推送到 github 时,我得到:

Warning: Permanently added the RSA host key for IP address '140.82.112.4' to the list of known hosts.
Enumerating objects: 47, done.
Counting objects: 100% (47/47), done.
Delta compression using up to 8 threads
Compressing objects: 100% (39/39), done.
Writing objects: 100% (47/47), 756.22 KiB | 9.11 MiB/s, done.
Total 47 (delta 7), reused 0 (delta 0), pack-reused 0
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly
client_loop: send disconnect: Broken pipe

当我运行 git remote -v:

origin  git@github.com:crwils/react_unit_and_cypresstesting.git (fetch)
origin  git@github.com:crwils/react_unit_and_cypresstesting.git (push)

尝试增加 git 缓冲区大小:

git config --global http.postBuffer 157286400

基于此处发现的各种其他类似问题/解决方案,我也尝试过:

  • git 重新打包
  • 删除和创建新的 SSH 密钥
  • 删除 .git 文件并重新初始化 repo 然后推送
  • 删除 .git 文件,将所有文件移动到新文件夹,在本地初始化新仓库,然后推送到 github 上的新远程仓库
  • 更改为不同的互联网连接

这只是从一些现有的和新的 repo 开始发生的,但不是其他的,没有明显的主题。

有人可以帮忙吗?

【问题讨论】:

  • http.postbuffer 对 SSH 没有影响,除非您确定需要它,否则不应使用它。当它修复问题时,表明远程服务器或您的网络不符合 1999 年编写的标准,应该予以修复。
  • 不过,您的问题可能是某种网络问题。除了标准网络问题外,代理和非默认防病毒和防火墙程序也可能是此类问题的根源。

标签: git repository broken-pipe


【解决方案1】:

首先检查使用 HTTPS 代替 SSH 是否可行:这将隔离 SSH 端口 22 上的问题。

cd /path/to/react_unit_and_cypresstesting
git remote set-url https://github.com/crwils/react_unit_and_cypresstesting.git
git push

您必须输入您的 GitHub 用户名/密码,但它们可以缓存在凭证助手中。

【讨论】:

  • 感谢 Von,所以我尝试了这个,并且在更改为 HTTPS 时效果很好。那么问题出在 SSH 上吗?
  • @Craig 是的。例如,在公司环境中,我肯定无法使用 SSH。
  • 我明白了,谢谢你的帮助。实际上,我只是尝试从 HTTPS 返回 SSH,并且使用 git remote set-url origin git@github.com:crwils/vu_app_project.git 似乎有效。我可以做些什么来解决 SSH 问题吗?
  • @Craig ssh -Tv git@github.com 有效吗?
  • 它似乎运行良好,然后以下面的结尾。在尝试将 repo 推送到 github 而不先切换到 HTTPS 时,SSH 问题仍然存在。 You've successfully authenticated, but GitHub does not provide shell access. debug1: channel 0: free: client-session, nchannels 1 Transferred: sent 3452, received 2868 bytes, in 0.2 seconds Bytes per second: sent 15588.6, received 12951.4 debug1: Exit status 1
【解决方案2】:

唯一的解决方案是先使用 HTTPS,然后切换到 SSL,例如

git remote set-url origin [HTTPS: https://github.com/username/your-repo-name]
git remote set-url origin [SSH: git@github.com:username/your-repo-name]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-04
    • 2013-02-20
    • 1970-01-01
    • 2012-08-19
    • 2012-06-08
    • 2011-05-04
    相关资源
    最近更新 更多