修复了通过 SSH 推送到 bitbucket repo 时的 "send disconnect" 错误

Fix for "send disconnect" error when pushing to bitbucket repo via SSH

我有一个之前没有推送到 bitbucket 的本地存储库。

我的工作文件夹(包含本地 .git 文件夹)已增长到 1.7 GB,因此我决定将其推送到 bitbucket,作为额外的备份。

  1. 我创建了一个新的 bitbucket 存储库 (workspace/repository.git)
  2. 在我的本地存储库中,我添加了一个名为“origin”的新 SSH 远程 (git@bitbucket.org:workspace/repository.git)
  3. 请注意,id_rsa 密钥已在本地和 bitbucket 中设置(对于其他项目)
  4. 现在,我尝试 git push 但总是失败并出现以下错误:

输出:

> git push

Pushing to git@bitbucket.org:workspace/repository.git
Enumerating objects: 62975, done.
Counting objects:   0% (1/62975)
Counting objects:   1% (630/62975)
...
Counting objects:  99% (62346/62975)
Counting objects: 100% (62975/62975)
Counting objects: 100% (62975/62975), done.
Delta compression using up to 12 threads
Compressing objects:   0% (1/33144)
Compressing objects:   1% (332/33144)
...
Compressing objects:  99% (32813/33144)
Compressing objects: 100% (33144/33144)
Compressing objects: 100% (33144/33144), done.
Writing objects:   0% (1/62975)
Writing objects:   1% (632/62975)
Writing objects:   1% (1094/62975), 3.45 MiB | 2.79 MiB/s
...
Writing objects:  29% (18265/62975), 70.41 MiB | 1.13 MiB/s
Writing objects:  29% (18282/62975), 71.57 MiB | 1.16 MiB/s
client_loop: send disconnect: Broken pipe
fatal: the remote end hung up unexpectedly
fatal: the remote end hung up unexpectedly

基于类似的问题,我已经尝试将~/.ssh/config更新为:

> cat ~/.ssh/config

Host *
   ServerAliveInterval 600
   TCPKeepAlive yes
   IPQoS=throughput

错误发生在 30-60 秒后 - 它总是在不同的位置失败。

什么会导致该问题,如何解决?

我认为这与 SSH 密钥无关,它确实可以正确地向 BitBucket 验证您的身份。

这与 BitBucket repository size limit, as listed here 有更多联系:如果您有超过 1GB 的巨大提交,将无法上传。

尝试在您的本地存储库上使用 github/git-sizer 之类的工具,不仅可以评估存储库的全局大小,还可以评估其最大对象的大小。