153

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

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

我已经完成了

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

4

18 回答 18

240

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

nginx的解决方案

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

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

Apache的解决方案

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

我希望这有帮助。

于 2013-02-22T10:16:12.720 回答
59

我想到了!!!我当然会在我发帖后马上!

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

于 2011-09-20T18:17:58.280 回答
39

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

git remote set-url origin git@github.com:GitUserName/GitRepoName.git

origin 这里是我的遥控器的名称(做 git remote,出来的是你的起源)。

于 2011-10-10T00:10:58.393 回答
13

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

所以我不得不设置

client_max_body_size 50m; 

在两个配置文件中:

  • 在 gitlab nginx 网络服务器上(如前面的答案中所述)
  • 还可以在专用服务器上托管的 nginx 反向代理上。
于 2015-05-05T21:35:41.437 回答
11

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

git config --global http.postBuffer 157286400

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

于 2018-10-22T16:31:13.463 回答
6

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

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

git push -u origin master

于 2013-08-20T15:17:19.233 回答
4

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

你需要增加你的uploadReadAheadSize.

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

  1. 展开服务器字段

  2. 扩展站点

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

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

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

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

  7. 点击Apply

  8. 重新启动网站

于 2014-04-17T07:51:34.780 回答
2

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

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

  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. 修改git地址为ssh链接。
git remote set-url origin git@github.com:[user_name]/[project_name].git

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

于 2019-07-16T07:55:20.387 回答
1

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

以下 URL 在 Windows 中为我工作

http://swamy@git.swamy.com/scm/project/swamy-main.git

而下面的 URL 在 Linux 机器上工作并且它在 URL 中有 https

https://swamy@git.swamy.com/scm/project/swamy-main.git
于 2013-08-03T16:00:09.373 回答
1

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

于 2015-03-10T16:26:55.403 回答
1

错误发生在“libcurl”中,它是 https 上传的底层协议。解决方案是以某种方式升级 libcurl。要获取有关错误的更多详细信息,请设置 GIT_CURL_VERBOSE=1

https://confluence.atlassian.com/pages/viewpage.action?pageId=306348908

错误的含义,根据 libcurl 文档:CURLE_HTTP_RETURNED_ERROR (22)

如果 CURLOPT_FAILONERROR 设置为 TRUE 并且 HTTP 服务器返回 >= 400 的错误代码,则会返回此信息。

http://curl.haxx.se/libcurl/c/libcurl-errors.html

于 2012-12-12T03:25:38.640 回答
1

需要将远程 url 更改为ssh或 https

git remote set-url origin git@github.com:laravel/laravel.git

或者

git remote set-url origin https://github.com/laravel/laravel.git

希望,这会有所帮助:)

于 2019-04-17T16:09:02.490 回答
0

https 克隆 gists 失败(ssh 有效,见下文):

12:00 jean@laptop:~/tmp$ GIT_CURL_VERBOSE=1 git clone https://gist.github.com/123456.git username
Initialized empty Git repository in /home/jean/tmp/username/.git/
* Couldn't find host gist.github.com in the .netrc file; using defaults
* About to connect() to gist.github.com port 443 (#0)
*   Trying 192.30.252.142... * Connected to gist.github.com (192.30.252.142) port 443 (#0)
* found 141 certificates in /etc/ssl/certs/ca-certificates.crt
*        server certificate verification OK
*        common name: *.github.com (matched)
*        server certificate expiration date OK
*        server certificate activation date OK
*        certificate public key: RSA
*        certificate version: #3
*        subject: C=US,ST=California,L=San Francisco,O=GitHub\, Inc.,CN=*.github.com
*        start date: Mon, 30 Apr 2012 00:00:00 GMT
*        expire date: Wed, 09 Jul 2014 12:00:00 GMT
*        issuer: C=US,O=DigiCert Inc,OU=www.digicert.com,CN=DigiCert High Assurance CA-3
*        compression: NULL
*        cipher: ARCFOUR-128
*        MAC: SHA1
> GET /123456.git/info/refs?service=git-upload-pack HTTP/1.1
User-Agent: git/1.7.1
Host: gist.github.com
Accept: */*
Pragma: no-cache

< HTTP/1.1 301 Moved Permanently
< Server: GitHub.com
< Date: Fri, 01 Nov 2013 05:00:51 GMT
< Content-Type: text/html
< Content-Length: 178
< Location: https://gist.github.com/gist/123456.git/info/refs?service=git-upload-pack
< Vary: Accept-Encoding
<
* Ignoring the response-body
* Expire cleared
* Connection #0 to host gist.github.com left intact
* Issue another request to this URL: 'https://gist.github.com/gist/123456.git/info/refs?service=git-upload-pack'
* Couldn't find host gist.github.com in the .netrc file; using defaults
* Re-using existing connection! (#0) with host gist.github.com
* Connected to gist.github.com (192.30.252.142) port 443 (#0)
> GET /gist/123456.git/info/refs?service=git-upload-pack HTTP/1.1
User-Agent: git/1.7.1
Host: gist.github.com
Accept: */*
Pragma: no-cache

< HTTP/1.1 200 OK
< Server: GitHub.com
< Date: Fri, 01 Nov 2013 05:00:52 GMT
< Content-Type: application/x-git-upload-pack-advertisement
< Transfer-Encoding: chunked
< Expires: Fri, 01 Jan 1980 00:00:00 GMT
< Pragma: no-cache
< Cache-Control: no-cache, max-age=0, must-revalidate
< Vary: Accept-Encoding
<
* Connection #0 to host gist.github.com left intact
* Couldn't find host gist.github.com in the .netrc file; using defaults
* About to connect() to gist.github.com port 443 (#0)
*   Trying 192.30.252.142... * connected
* Connected to gist.github.com (192.30.252.142) port 443 (#0)
* found 141 certificates in /etc/ssl/certs/ca-certificates.crt
* SSL re-using session ID
*        server certificate verification OK
*        common name: *.github.com (matched)
*        server certificate expiration date OK
*        server certificate activation date OK
*        certificate public key: RSA
*        certificate version: #3
*        subject: C=US,ST=California,L=San Francisco,O=GitHub\, Inc.,CN=*.github.com
*        start date: Mon, 30 Apr 2012 00:00:00 GMT
*        expire date: Wed, 09 Jul 2014 12:00:00 GMT
*        issuer: C=US,O=DigiCert Inc,OU=www.digicert.com,CN=DigiCert High Assurance CA-3
*        compression: NULL
*        cipher: ARCFOUR-128
*        MAC: SHA1
> POST /123456.git/git-upload-pack HTTP/1.1
User-Agent: git/1.7.1
Host: gist.github.com
Accept-Encoding: deflate, gzip
Content-Type: application/x-git-upload-pack-request
Accept: application/x-git-upload-pack-result
Content-Length: 116

< HTTP/1.1 301 Moved Permanently
< Server: GitHub.com
< Date: Fri, 01 Nov 2013 05:00:53 GMT
< Content-Type: text/html
< Content-Length: 178
< Location: https://gist.github.com/gist/123456.git/git-upload-pack
< Vary: Accept-Encoding
<
* Ignoring the response-body
* Connection #0 to host gist.github.com left intact
* Issue another request to this URL: 'https://gist.github.com/gist/123456.git/git-upload-pack'
* Violate RFC 2616/10.3.2 and switch from POST to GET
* Couldn't find host gist.github.com in the .netrc file; using defaults
* Re-using existing connection! (#0) with host gist.github.com
* Connected to gist.github.com (192.30.252.142) port 443 (#0)
> GET /gist/123456.git/git-upload-pack HTTP/1.1
User-Agent: git/1.7.1
Host: gist.github.com
Accept-Encoding: deflate, gzip
Content-Type: application/x-git-upload-pack-request
Accept: application/x-git-upload-pack-result

* The requested URL returned error: 400
* Closing connection #0
error: RPC failed; result=22, HTTP code = 400

这有效:git clone git@gist.github.com:123456.git

于 2013-11-01T05:14:33.547 回答
0

我有同样的问题(在 Win XP 上),我将 Git bin 目录中的 libcurl-4.dll 文件更新为来自http://www.paehl.com/open_source/?download=curl_DLL_ONLY.7z的 SSL 版本(重命名到 libcurl4.dll)。现在一切正常。

于 2013-01-28T16:16:11.583 回答
0

当我使用 https url 推送到远程主机时,我遇到了同样的问题,我将其更改为 SSH 地址,一切恢复正常。

于 2019-08-31T01:29:17.620 回答
0

面临同样的问题。在我的情况下,访问(拉/推)同一个项目的多个用户之间的 GIT 版本不兼容。

刚刚更新了 GIT 版本并更新了 Android Studio 设置的路径,它对我来说工作正常。

编辑 -

Git for Windows (1.9.5) 有一些问题,更新相同可能会有所帮助。

于 2016-02-03T11:37:00.137 回答
0

面临同样的问题,但它通过清理 git 存储库得到解决(使用“git clean”清理未跟踪的文件)。

于 2017-09-08T06:18:58.887 回答
0

我能够通过增加文件 /etc/gitlab/gitlab.rb 中以下行 nginx['client_max_body_size'] = 'Xm' 的大小来解决这个问题

X=你的价值。默认值为 250。

更新文件后,运行重新配置命令 gitlab-ctl reconfigure

于 2021-07-11T18:36:27.997 回答