当我试图逃跑的时候

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

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


当前回答

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

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

其他回答

如果使用GitHub,在repo目录下,运行此命令设置http。postBuffer似乎是它的最大允许值GitHub:

git config http.postBuffer 2147483648

如果使用git clone克隆一个repo,可以使用相同的选项克隆它:

git clone -c http.postBuffer=2147483648 git@github.com:myuser/myrepo.git /path/to/myrepo

在这两种情况下,上述数字都相当于2 GiB。然而,您可能需要达到这个数量的空闲内存才能使用这个值。

确保每次推送到GitHub都提交不超过这个大小的更改。事实上,为了安全起见,我会将提交推的大小保持在1.8 GiB以下。这可能需要将一个较大的提交划分为较小的提交和推送。

为什么是这个值?

之所以使用这个特定的值,是因为至少在2018年,这个值被记录为GitHub的推送大小限制:

我们不允许超过2GB的推送

为什么不放低一点呢?

一些先前的答案说将其设置为524288000 (500 MiB),但这个数字似乎是任意的,没有价值。任何较低的值都可以工作,只要您的推送大小不大于设置的值。

为什么不设高一点呢?

如果你将这个值设置为高于2 GiB,并且如果你尝试的推送大小也更高,你可以期待GitHub的文档错误:

远程:致命:包超过允许的最大大小

即使配置了后缓冲区,这个问题也没有解决。

当我把我的wifi网络从宽带改为移动热点时,我的问题解决了。这可能不是逻辑上正确的答案,但它解决了问题。

确保你有良好的网速。

对我们来说,问题是我们有大量的文件应该由git lfs来管理。

我们采取了以下措施来解决问题:

# Soft reset so you can author a new commit
git reset --soft HEAD~1

# Install git lfs
git lfs install

# Track large files of a specified file type YMMV
git lfs track "*.uasset" "*.umap"

# Re-add everything
git add .

# Author a new commit
git commit -m "git lfs ftw"

# Push
git push

我也得到了这个错误。第二次推就成功了

当我在.ssh中有不正确的keypair时,我得到这个错误。将pubkey添加到github(在设置中)为我修复了这个问题。