git Github 推送错误:RPC 失败;结果=22,HTTP 代码 = 413

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

Github Push Error: RPC failed; result=22, HTTP code = 413

gitgithubgit-tower

提问by Sneakyness

stupid issue with Github going on right now. I have a decent amount of changes (~120MB in size), when I attempt to push, this is what happens:

Github 的愚蠢问题正在发生。我有相当多的更改(大小约为 120MB),当我尝试推送时,会发生以下情况:

error: RPC failed; result=22, HTTP code = 413
fatal: The remote end hung up unexpectedly 
fatal: The remote end hung up unexpectedly

I've already done

我已经做了

git config http.postBuffer 524288000, so that doesn't seem to be the issue. What could it be?

git config http.postBuffer 524288000,所以这似乎不是问题。会是什么呢?

采纳答案by Sneakyness

I figured it out!!! Of course I would right after I hit post!

我想到了!!!我当然会在我点击帖子后立即!

I had the repo set to use the HTTPS url, I changed it to the SSH address, and everything resumed working flawlessly.

我将 repo 设置为使用 HTTPS url,我将其更改为 SSH 地址,一切都恢复正常工作。

回答by Tinou

If you get error 413, then the issue doesn't lie with git but with your web server. It's your web server that is blocking big upload files.

如果您收到错误 413,那么问题不在于 git 而在于您的 Web 服务器。是您的 Web 服务器阻止了大型上传文件。

Solution for nginx

nginx的解决方案

Just load your nginx.confand add client_max_body_size 50m;( changing the value to your needs ) in the http block.

只需在 http 块中加载nginx.conf并添加client_max_body_size 50m;(根据需要更改值)。

Reload nginx to accept the new config by executing sudo service nginx reloadand try again to push your commit over http.

通过执行重新加载 nginx 以接受新配置,sudo service nginx reload然后再次尝试通过 http 推送您的提交。

Solution for Apache

阿帕奇解决方案

In your httpd.confadd LimitRequestBody 52428800( changing the value to your needs ) inside a <Directory />block. Doing this you can limit the request of the whole server filesystem, just a single Virtual Host or a directory.

在您httpd.conf添加LimitRequestBody 52428800(根据您的需要更改值)中的一个<Directory />块中。这样做你可以限制整个服务器文件系统的请求,只有一个虚拟主机或一个目录。

I hope this helps.

我希望这有帮助。

回答by kay am see

command to change the remote url ( from https -> git@... ) is something like this

更改远程 url(从 https -> git@... )的命令是这样的

git remote set-url origin [email protected]:GitUserName/GitRepoName.git

origin here is the name of my remote ( do git remote and what comes out is your origin ).

这里的 origin 是我的遥控器的名称(执行 git remote 并且出现的是您的 origin )。

回答by grimabe

I had the same problem but I was using a reverse proxy.

我有同样的问题,但我使用的是反向代理。

So I had to set

所以我不得不设置

client_max_body_size 50m; 

inside both configure files :

在两个配置文件中:

  • on the gitlab nginx web server (as said inside the previous answers)
  • but also on the nginx reverse proxy hosted on the dedicated server.
  • 在 gitlab nginx web 服务器上(如前面的答案所述)
  • 但也在专用服务器上托管的 nginx 反向代理上。

回答by Jayzcode

I already had "HTTPS//" in the git URL yet faced this error.

我在 git URL 中已经有“HTTPS//”但遇到了这个错误。

All I did was to add option -u with push and it worked.

我所做的只是添加选项 -u 和 push 并且它起作用了。

git push -u origin master

git push -u origin master

回答by Markus Mauch

For those who use IIS 7to host a git http/httpsendpoint:

对于使用IIS 7托管 git http/https端点的用户:

You need to increase your uploadReadAheadSize.

你需要增加你的uploadReadAheadSize.

Launch Internet Information Services (IIS) Manager

启动Internet 信息服务 (IIS) 管理器

  1. Expand the Server field

  2. Expand Sites

  3. Select the site you want to make the modification for.

  4. In the Features section, double click Configuration Editor

  5. Under Sectionselect: system.webServer > serverRuntime

  6. Modify the uploadReadAheadSizesection (The value must be between 0and 2147483647.)

  7. Click Apply

  8. Restart the Website

  1. 展开服务器字段

  2. 展开站点

  3. 选择要对其进行修改的站点。

  4. 在功能部分,双击 Configuration Editor

  5. Section选择下:system.webServer > serverRuntime

  6. 修改uploadReadAheadSize部分(值必须在0和之间2147483647。)

  7. 点击 Apply

  8. 重新启动网站

回答by vitthal

If you are facing this issue while pushing changes in big size then run below command in terminal.

如果您在推送大尺寸更改时遇到此问题,请在终端中运行以下命令。

git config --global http.postBuffer 157286400

See thisfor more details.

有关更多详细信息,请参阅内容。

回答by Zhenjie Yan

Do you use https links instead of ssh links? Because the https link is limited by the size of the upload of HttpServer (such as Apache, Ngnix), there is no such restriction when using ssh.

你使用 https 链接而不是 ssh 链接吗?因为https链接受HttpServer(如Apache、Ngnix)上传大小的限制,所以使用ssh时没有这样的限制。

Use the following method to switch to the ssh link.

使用以下方法切换到ssh链接。

  1. Open terminal.
  2. Switch to your project's working directory.
  3. Get the name of the remote repository
  1. 打开终端。
  2. 切换到项目的工作目录。
  3. 获取远程仓库的名称
$ git remote -v
origin  https://github.com/[user_name]/[project_name].git (fetch)
origin  https://github.com/[user_name]/[project_name].git (push)
  1. Modify the git address to ssh link.
  1. 修改git地址为ssh链接。
git remote set-url origin [email protected]:[user_name]/[project_name].git

If you determine the remote repository name, proceed directly to step 4. Now, you can do the push operation happily.

如果确定了远程仓库名称,直接进行第4步,现在就可以愉快的进行push操作了。

回答by Ben

I had this error (error: RPC failed; result=22, HTTP code = 413) when I tried to push my initial commit to a new BitBucket repository. The error occurred for me because the BitBucket repo had no masterbranch. If you are using SourceTreeyou can create a master branch on the origin by pressing the Git Flow button.

当我尝试将初始提交推送到新的 BitBucket 存储库时出现此错误(错误:RPC 失败;结果=22,HTTP 代码 = 413)。错误发生在我身上,因为 BitBucket 存储库没有主分支。如果您正在使用SourceTree,您可以通过按Git Flow 按钮在源上创建一个主分支。

回答by Swamy

I got this problem when I try to clone a git repo in Linux machine.

当我尝试在 Linux 机器上克隆 git repo 时遇到了这个问题。

the following URL is working for me in windows

以下 URL 在 Windows 中对我有用

http://[email protected]/scm/project/swamy-main.git

whereas the following URL works in Linux machine and it has https in URL

而以下 URL 在 Linux 机器上有效,并且 URL 中有 https

https://[email protected]/scm/project/swamy-main.git