当我试图逃跑的时候

git push origin master --force

我刚刚

Counting objects: 2649, done.
Delta compression uses up to 2 threads.
Compressing objects: 100% (1280/1280), done.
error: RPC failed; result=22, HTTP code = 413 | 116 KiB/s   
fatal: The remote end hung up unexpectedly
Writing objects: 100% (2504/2504), 449.61 MiB | 4.19 MiB/s, done.
Total 2504 (delta 1309), reused 2242 (delta 1216)
fatal: The remote end hung up unexpectedly
Everything up-to-date

这和缺乏安全感有关吗?我尝试创建一个公钥作为致命的答案:远程端意外挂断并重新运行它,但它仍然不工作。我不是在用钥匙吗?如果是,我该如何使用它?


当前回答

另一个补充,因为我遇到这个错误不同的方式和谷歌把我带到这里。

我的问题是箱子不匹配;一只骆驼箱,一只没有。显然,GIT会在不告诉你原因的情况下阻止你这么做。因此,如果您的分支只在大小写上与远程分支不同,请尝试将它们更改为相同。

看到的: Git:合并后'Master无法解析为分支'

其他回答

这看起来类似于我如何让github默认为ssh,而不是https的新存储库。 也许从http协议切换到ssh协议是值得的:

$ git remote add origin git@github.com:username/project.git

上面的答案对我都没用,但下面的答案对我有用。

从项目中删除.git/ 克隆远程回购到一些新的位置,如你的桌面: Git克隆https://github.com/foo/bar.git 将.git/从新位置移动到旧位置 重新提交并推动您的更改

在我们的案例中,问题是一个克隆程序编写了一个.git/config文件,其中包含一个url条目,该url条目是一个只读访问方法。将url从://方法更改为@方法解决了这个问题。

运行git remote -v可以解释这个问题。

基于您正在使用的推送到回购的协议

HTTP

git config --global http.postBuffer 157286400

引用:

https://git-scm.com/docs/git-config#Documentation/git-config.txt-httppostBuffer

SSH

在~/中添加以下内容。Linux机器中的Ssh /config文件

Host your-gitlab-server.com
  ServerAliveInterval 60
  ServerAliveCountMax 5
  IPQoS throughput

引用:

https://docs.gitlab.com/ee/topics/git/troubleshooting_git.html#check-your-ssh-configuration https://unix.stackexchange.com/questions/3026/what-options-serveraliveinterval-and-clientaliveinterval-in-sshd-config-exac https://communities.vmware.com/message/2778248

如果您推送的任何提交都是畸形的,也会发生这种情况。

我(不知不觉中)提交了一个畸形的作者电子邮件字段,但我得到的只是这个模糊的远程挂断错误消息。我能够推送其他分支,而不是这个分支,所以我开始推送来自“坏”分支的提交,直到我最终降落在:

Pushing to git@github.com:directangular/unicorn.git
Counting objects: 100% (9/9), done.
Delta compression using up to 20 threads
Writing objects: 100% (5/5), 549 bytes | 549.00 KiB/s, done.
Total 5 (delta 4), reused 0 (delta 0)
remote: error: object 74c7584ff0b93591c19d3a3c19695889dd2274d2: badEmail: invalid author/committer line - bad email        
remote: fatal: fsck error in packed object        
error: remote unpack failed: index-pack abnormal exit
To github.com:directangular/unicorn.git
 ! [remote rejected]       pizzafeast -> pizzafeast (failed)
error: failed to push some refs to 'git@github.com:directangular/unicorn.git'

因此,看起来远程端意外挂起的错误有点像“吞下”实际的错误消息,这可能是我在这里看到的某种畸形提交。

在修复了错误的电子邮件后,我能够很好地推动。