Git,致命:远端意外挂断

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15240815/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 15:40:04  来源:igfitidea点击:

Git, fatal: The remote end hung up unexpectedly

gitgithub

提问by DanielLC

When I tried to run

当我试图跑

git push origin master --force

I just got

我刚得到

Counting objects: 2649, done.
Delta compression using 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

Is it something to do with not being secure? I tried creating a public key as in the answer for Fatal: The remote end hung up unexpectedlyand running it again, but it still doesn't work. Am I not actually using the key? If so, how do I use it?

这与不安全有关吗?我尝试创建一个公钥,如致命的答案:远程端意外挂断并再次运行它,但它仍然不起作用。我实际上没有使用密钥吗?如果是这样,我该如何使用它?

采纳答案by Vitalliuss

This looks similar to How do I get github to default to ssh and not https for new repositories. Probably it's worth trying to switch from http protocol to ssh:

这看起来类似于How do I get github to default to ssh and not https for new repositories。可能值得尝试从 http 协议切换到 ssh:

$ git remote add origin [email protected]:username/project.git

回答by Roman M

The problem is due to git/https buffer settings. In order to solve it (taken from Git fails when pushing commit to github)

问题是由于 git/https 缓冲区设置造成的。为了解决它(从Git 推送提交到 github 时失败

git config http.postBuffer 524288000

And run the command again

并再次运行命令

回答by Chinu

Cause : The default file post size for Git has been exceeded.

原因:已超出 Git 的默认文件发布大小。

Solution :

解决方案 :

Navigate to repo.

导航到回购。

Run the following command to increase the buffer to 500MB after navigating to the repository:

导航到存储库后,运行以下命令将缓冲区增加到 500MB:

git config http.postBuffer 524288000

回答by niksmac

You might get an error like this

你可能会收到这样的错误

error: could not lock config file .git/config: No such file or directory

错误:无法锁定配置文件 .git/config:没有那个文件或目录

that is because you dont have a local .git/configfile You can get it working by this command

那是因为你没有本地.git/config文件你可以通过这个命令让它工作

git config --global http.postBuffer 524288000

git config --global http.postBuffer 524288000

回答by Shameen

Other solutions didn't work in my case, doing a garbage collection fixed it for me:

其他解决方案在我的情况下不起作用,进行垃圾收集为我修复了它:

git gc --aggressive

git gc --aggressive

回答by MikeB

Contrary to one of the other answers - I had the problem on push using ssh - I switched to https and it was fixed.

与其他答案之一相反 - 我在使用 ssh 推送时遇到了问题 - 我切换到 https 并已修复。

git remote remove origin
git remote add origin https://github..com/user/repo
git push --set-upstream origin master

回答by Loilo

This error can also be thrown through missing write permissionson the repository.

此错误也可能因缺少存储库的写入权限而引发。



My concrete case went like this:

我的具体案例是这样的:

  1. I created a repo with the rootuser of my server (via SSH).
  2. I installed a git serviceand created a gitlinux user that should manage all git-related action.
  3. By that time, I had forgotten that the repo was created with the rootuser in the first place, and the gituser simply didn't have the file permissions to write anything into the repository.
  1. 我与root我的服务器的用户(通过 SSH)创建了一个 repo 。
  2. 我安装了一个 git 服务并创建了一个gitlinux 用户,该用户应该管理所有与 git 相关的操作。
  3. 到那时,我已经忘记了 repo 最初是由root用户创建的,而git用户根本没有将任何内容写入存储库的文件权限。

回答by t0dd

Culprit (in my case):
A high-latency network.

罪魁祸首(就我而言):
高延迟网络。

This is not an answer per se but more of an observation that may help others. I found that this error pops up occasionally on high-latency networks (I have to use a Satellite dish for internet access for example). The speed of the network is fine, but the latency can be high. Note: The problem only exists in certain scenarios, but I have not determined what the pattern is.

这本身并不是一个答案,而是更多的观察结果,可以帮助其他人。我发现这个错误偶尔会在高延迟网络上弹出(例如,我必须使用卫星天线来访问互联网)。网络速度很好,但延迟可能很高。注意:问题只存在于某些场景,但我还没有确定是什么模式。

Temporary mitigation:
I switched networks—I moved to a slower, but lower latency cell network (my phone used as a hotspot)—and the problem disappeared. Note that I can only do this itermittently because my cell connectivity is also intermittent. Plus the bandwidth usage adds costs. I'm also lucky that I have this option available to me. Not everyone does.

临时缓解措施:
我切换了网络——我转向了速度较慢但延迟较低的蜂窝网络(我的手机用作热点)——问题消失了。请注意,我只能间歇性地执行此操作,因为我的单元连接也是间歇性的。此外,带宽使用会增加成本。我也很幸运,我可以使用这个选项。不是每个人都这样。

I'm sure there is some configuration setting somewhere that makes git—or ssh or curl or whatever times out first—more tolerant of such networks, but I don't know what it is.

我确信某处有一些配置设置可以让 git——或 ssh 或 curl 或任何先超时的东西——更能容忍这样的网络,但我不知道它是什么。

A plea to developers:
These kinds of issues are a constant problem for rural populations. Please think of us when you design your systems, tools, and applications. Thank you.

对开发商的恳求:
这类问题是农村人口一直存在的问题。当您设计系统、工具和应用程序时,请考虑我们。谢谢你。

回答by rrreee

If you are using git for windows (and you likely are, if you are doing this on a windows machine), and none of the other fixes here worked for you, try going to https://github.com/git-for-windows/git/releases, and getting a version on or after version 2.4.5. Fixed it right up for me.

如果您在 Windows 上使用 git(如果您在 Windows 机器上执行此操作,则可能是这样),并且此处的其他修复程序均不适合您,请尝试访问https://github.com/git-for- windows/git/releases,并获取版本 2.4.5 或之后的版本。为我修好了。

回答by Marcos Bahiense

You probably did clone the repository within an existing one, to solve the problem can simply clone of the repository in another directory and replicate the changes to this new directory and then run the push.

您可能确实在现有存储库中克隆了存储库,要解决该问题,只需将存储库克隆到另一个目录中并将更改复制到这个新目录,然后运行推送。