git push 失败:RPC 失败;结果=22,HTTP 代码 = 411

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12651749/
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 14:41:38  来源:igfitidea点击:

git push fails: RPC failed; result=22, HTTP code = 411

gitgithub

提问by Zening Qu

I have only one branch. For a few months I have been using

我只有一个分支。几个月来我一直在使用

git push origin master

to commit to my local repository. Last night after I made some minor changes to my local repository and tried to push using the same command, I got this error:

提交到我的本地存储库。昨晚,在我对本地存储库进行了一些小的更改并尝试使用相同的命令进行推送后,出现了以下错误:

error: RPC failed; result=22, HTTP code = 411
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Everything up-to-date

I googled and found questions such as this oneand this one, but none of the answers to these questions solves my problem.

我用谷歌搜索并发现了诸如this onethis之类的问题,但这些问题的答案都没有解决我的问题。

Most of the answers suggest the problem of detached head. Yet I don't think my head is detached. Nor do I think I am on the wrong branch (as I only have one branch...)

大多数答案都暗示了头分离的问题。然而我不认为我的头是超然的。我也不认为我在错误的分支上(因为我只有一个分支......)

I did a few experiments to figure out what's wrong, and here are the results I got:

我做了一些实验来找出问题所在,以下是我得到的结果:

(1) First comes my git statusoutput

(1) 首先是我的git status输出

# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
# egal.aux
# egal.blg
# egal.out
# egal.pdf
# egalcar.aux
# egalcar.blg
# egalcar.pdf
nothing added to commit but untracked files present (use "git add" to track)
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
# egal.aux
# egal.blg
# egal.out
# egal.pdf
# egalcar.aux
# egalcar.blg
# egalcar.pdf
nothing added to commit but untracked files present (use "git add" to track)

(2) When I type git reflog, I can see all my local commits, but the remote repository just won't get updated.

(2) 当我输入时git reflog,我可以看到我所有的本地提交,但是远程存储库不会得到更新。

(3) When I type git branch -a, I get

(3) 当我输入时git branch -a,我得到

* master
  remotes/origin/master
* master
  remotes/origin/master

(4) When I type git remote show origin, I get

(4) 当我输入时git remote show origin,我得到

* remote origin
  Fetch URL: http://github.com/CherryQu921/egaldoc_en
  Push  URL: http://github.com/CherryQu921/egaldoc_en
  HEAD branch: master
  Remote branch:
    master tracked
  Local ref configured for 'git push':
    master pushes to master (fast-forwardable)
* remote origin
  Fetch URL: http://github.com/CherryQu921/egaldoc_en
  Push  URL: http://github.com/CherryQu921/egaldoc_en
  HEAD branch: master
  Remote branch:
    master tracked
  Local ref configured for 'git push':
    master pushes to master (fast-forwardable)

I think the last line of output (the "fast-forwardable") is weird, but I am not sure what is wrong...

我认为输出的最后一行(“快进”)很奇怪,但我不确定有什么问题......

回答by Maksym Polshcha

If you attempt to push a large set of changes to a Git repository with HTTP or HTTPS, you may get an error message such as error: RPC failed; result=22, HTTP code = 411. This is caused by a Git configuration default which limits certain HTTP operations to 1 megabyte.

如果您尝试使用 HTTP 或 HTTPS 将大量更改推送到 Git 存储库,您可能会收到错误消息,例如 error: RPC failed; result=22, HTTP code = 411。这是由 Git 配置默认值导致的,该配置将某些 HTTP 操作限制为 1 兆字节。

To change this limit run within your local repository

要更改此限制,请在本地存储库中运行

git config http.postBuffer *bytes*

where bytes is the maximum number of bytes permitted. For example:

其中 bytes 是允许的最大字节数。例如:

git config http.postBuffer 524288000

For 500MB (thanks @Hengjie)

500MB(感谢@Hengjie)

回答by jdr0dn3y

You can also do this globally -

您也可以在全球范围内执行此操作-

git config --global http.postBuffer 524288000

That will allow all local repos to push up to 500MB of data.

这将允许所有本地存储库推送多达 500MB 的数据。

回答by javaauthority

None of the solutions provided worked for us. We had to switch to sshto make this work instead of the HTTPSsolution.

提供的任何解决方案都不适合我们。我们不得不切换到ssh使这项工作而不是HTTPS解决方案。

回答by Errepunto

If you are using TortoiseGit for Windows, the easiest way is using the integrated configuration.

如果您使用的是 Windows 版 TortoiseGit,最简单的方法是使用集成配置。

In a file explorer press left mouse button, select TortoiseGit -> Settings. Accept the info message. Now, you can choose if you want to configure the property only for the current project or system whide. For systemwide configuration press "edit systemwide gitconfig" and add the next line to the section [http]:

在文件浏览器中按鼠标左键,选择TortoiseGit -> Settings。接受信息消息。现在,您可以选择是仅为当前项目还是系统窗口配置属性。对于系统范围的配置,请按“编辑系统范围的 gitconfig”并将下一行添加到该部分[http]

postBuffer = 524288000

(it the section [http]doesn't exist, create it)

(如果该部分[http]不存在,请创建它)

回答by Rob Lassche

I solved the 22 error as follows: In the "git clone" command I did NOT supply the user:password. The clone worked, but not the push. Solution for the 22 error: Modify .git/config the url like this: url=http://user:pwd@host/... Then, the push worked.

我解决了 22 错误,如下所示:在“git clone”命令中,我没有提供用户:密码。克隆有效,但没有推动。22 错误的解决方法:修改 .git/config url 像这样: url= http://user:pwd@host/... 然后,推送成功了。