将提交推送到 github 时 Git 失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2702731/
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
Git fails when pushing commit to github
提问by Stephen Melvin
I cloned a git repo that I have hosted on github to my laptop. I was able to successfully push a couple of commits to github without problem. However, now I get the following error:
我将托管在 github 上的 git 存储库克隆到我的笔记本电脑上。我能够成功地将几次提交推送到 github,没有问题。但是,现在我收到以下错误:
Compressing objects: 100% (792/792), done.
error: RPC failed; result=22, HTTP code = 411
Writing objects: 100% (1148/1148), 18.79 MiB | 13.81 MiB/s, done.
Total 1148 (delta 356), reused 944 (delta 214)
From here it just hangs and I finally have to CTRL+ Cback to the terminal.
从这里它就挂了,我终于不得不CTRL+C回到终端。
回答by Will
I had the same issue and believe that it has to do with the size of the repo (edited- or the size of a particular file) you are trying to push.
我遇到了同样的问题,并认为这与您尝试推送的存储库的大小(已编辑或特定文件的大小)有关。
Basically I was able to create new repos and push them to github. But an existing one would not work.
基本上我能够创建新的存储库并将它们推送到 github。但是现有的一个行不通。
The HTTP error code seems to back me up it is a 'Length Required' error. So maybe it is too large to calc or greated that the max. Who knows.
HTTP 错误代码似乎支持我,它是“需要长度”错误。所以也许它太大而无法计算或超过最大值。谁知道。
EDIT
编辑
I found that the problem may be files that are large. I had one update that would not push even though I had successful pushes up to that point. There was only one file in the commit but it happened to be 1.6M
So I added the following config change
git config http.postBuffer 524288000
To allow up to the file size 500M and then my push worked. It may have been that this was the problem initially with pushing a big repo over the http protocol.
我发现问题可能是文件很大。我有一个更新不会推送,即使我已经成功推送到那个点。提交中只有一个文件,但恰好是 1.6M
所以我添加了以下配置更改
git config http.postBuffer 524288000
允许最大文件大小为 500M,然后我的推送有效。这可能是最初通过 http 协议推送大型 repo 的问题。
END EDIT
结束编辑
the way I could get it to work (EDIT before I modified postBuffer) was to tar up my repo, copy it to a machine that can do git over ssh, and push it to github. Then when you try to do a push/pull from the original server it should work over https. (since it is a much smaller amount of data than an original push).
我可以让它工作的方式(在我修改 postBuffer 之前编辑)是将我的 repo tar up,将它复制到一台可以通过 ssh 执行 git 的机器,然后将它推送到 github。然后,当您尝试从原始服务器执行推/拉操作时,它应该可以通过 https 运行。(因为它的数据量比原始推送要少得多)。
Hope this helps.
希望这可以帮助。
回答by Nikita Pushkar
If this command not help
如果这个命令没有帮助
git config http.postBuffer 524288000
git 配置 http.postBuffer 524288000
Try to change ssh method to https
尝试将 ssh 方法更改为 https
git remote -v
git remote rm origin
git remote add origin https://github.com/username/project.git
回答by VonC
Looks like a server issue (i.e. a "GitHub" issue).
If you look at this thread, it can happen when the git-http-backend
gets a corrupted heap.(and since they just put in place a smart http support...)
But whatever the actual cause is, it may also be related with recent sporadic disruption in one of the GitHub fileserver.
看起来像是服务器问题(即“GitHub”问题)。
如果您查看此线程,则可能会在git-http-backend
堆损坏时发生。(并且因为他们只是提供了智能 http 支持...)
但无论实际原因是什么,它也可能与最近的零星中断有关GitHub 文件服务器之一。
Do you still see this error message? Because if you do:
您是否仍然看到此错误消息?因为如果你这样做:
- check your local Git version (and upgrade to the latest one)
- report this as a GitHub bug.
- 检查您的本地 Git 版本(并升级到最新版本)
- 将此报告为GitHub 错误。
Note: the Smart HTTP Supportis a big deal for those of us behind an authenticated-based enterprise firewall proxy!
注意:对于我们这些基于身份验证的企业防火墙代理背后的人来说,智能 HTTP 支持是一件大事!
From now on, if you clone a repository over the
http://
url and you are using a Git client version 1.6.6 or greater, Git will automatically use the newer, better transport mechanism.
Even more amazing, however, is that you can now push over that protocol and clone private repositories as well. If you access a private repository, or you are a collaborator and want push access, you can put your username in the URL and Git will prompt you for the password when you try to access it.Older clients will also fall back to the older, less efficient way, so nothing should break - just newer clients should work better.
从现在开始,如果您通过
http://
url克隆存储库并且您使用的是 Git 客户端版本 1.6.6 或更高版本,Git 将自动使用更新、更好的传输机制。
然而,更令人惊奇的是,您现在可以推送该协议并克隆私有存储库。如果您访问私有仓库,或者您是协作者并希望推送访问,您可以将您的用户名放在 URL 中,当您尝试访问它时,Git 会提示您输入密码。老客户也会退回到旧的、效率较低的方式,所以没有什么应该中断 - 只有新客户应该工作得更好。
So again, make sure to upgrade your Git client first.
因此,再次确保先升级您的 Git 客户端。
回答by Vitaly Leskiv
Pushing from Git GUI instead of Bash works for me.
从 Git GUI 推送而不是 Bash 对我有用。
回答by BananaAcid
I tried to push to my own hosted bonobo-git server, and did not realise, that the http.postbuffer meant the project directory ...
我试图推送到我自己托管的 bonobo-git 服务器,但没有意识到 http.postbuffer 意味着项目目录......
so just for other confused ones:
所以只是对于其他困惑的:
why? In my case, I had large zip files with assets and some PSDs pushed as well - to big for the buffer I guess.
为什么?就我而言,我有包含资产的大型 zip 文件,并且还推送了一些 PSD - 我猜缓冲区很大。
How to do this http.postbuffer: execute that command within your project src directory, next to the .git folder, not on the server.
如何执行 http.postbuffer:在项目 src 目录中执行该命令,在 .git 文件夹旁边,而不是在服务器上。
be aware, large temp (chunk) files will be created of that buffer size.
请注意,将创建该缓冲区大小的大型临时(块)文件。
Note: Just check your largest files, then set the buffer.
注意:只需检查最大的文件,然后设置缓冲区。
回答by RahulMohan Kolakandy
in these cases you can try ssh if https is stuck.
在这些情况下,如果 https 卡住,您可以尝试 ssh。
Also you can try increasing the buffer size to an astronomical figure so that you dont have to worry about the buffer size any more git config http.postBuffer 100000000
您也可以尝试将缓冲区大小增加到一个天文数字,这样您就不必再担心缓冲区大小了 git config http.postBuffer 100000000
回答by Apurv Nerlekar
The Problem to push mostly is because of the size of the files that need to be pushed. I was trying to push some libraries of just size 2 mb, then too the push was giving error of RPC with result 7. The line is of 4 mbps and is working fine. Some subsequent tries to the push got me success. If such error comes, wait for few minutes and keep on trying.
推送的问题主要是因为需要推送的文件的大小。我试图推送一些大小仅为 2 mb 的库,然后推送也给出了 RPC 错误,结果为 7。该线路为 4 mbps,并且工作正常。随后的一些推动尝试让我成功了。如果出现此类错误,请等待几分钟并继续尝试。
I also found out that there are some RPC failures if the github is down or is getting unstable network at their side.
我还发现,如果 github 关闭或他们身边的网络变得不稳定,则会出现一些 RPC 失败。
So keeping up trying after some intervals is the only option!
因此,在一段时间后继续尝试是唯一的选择!