【问题标题】:Github Push Error: RPC failed; result=22, HTTP code = 413Github 推送错误:RPC 失败;结果 = 22,HTTP 代码 = 413
【发布时间】:2011-09-20 18:17:01
【问题描述】:

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,所以这似乎不是问题。会是什么呢?

【问题讨论】:

  • 对于未来的访问者,如果您收到HTTP code = 0,GitHub 就像昨天一样已关闭。
  • 当我的代理被阻塞时,我收到了HTTP code = 0。我的 http 代理适用于 github,但 https 不适用于我的公司代理。我认为我的 HTTPS 代理强制 NTLM,而 HTTP 接受 BASIC。我将回购源 URL 从 https 更改为 http,它对我有用。 git remote set-url origin http://github.com/GitUserName/GitRepoName.git

标签: git github git-tower


【解决方案1】:

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

nginx的解决方案

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

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

Apache 解决方案

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

我希望这会有所帮助。

【讨论】:

  • 50m 对我来说还不够,但这确实解决了我的问题!谢谢!
  • 我也必须在中间 nginx 代理上这样做。
  • 如果你不使用 Nginx 怎么办?
  • gitlab综合安装的任何解决方案..?最新版本 12.1
  • 经过多次搜索、咒骂和哭泣。 (按此顺序)我发现嵌入的配置文件位于:/var/opt/gitlab/nginx/conf/gitlab-http.conf
【解决方案2】:

我明白了!!!我当然会在我发帖后马上!

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

【讨论】:

  • 这不是问题的原因。这只是一种解决方法。我想知道为什么它在 https 上失败。
  • 对我来说 ssh 不是一个选项。因此,如果您处于相同的情况@ZincX,请参阅上面的答案。
  • 这只是一种解决方法。 Tinou 的答案应该是公认的答案。
  • 你是怎么改变的?
  • 许多人可能无法访问他们的网络服务器,因此非常感谢您提供此信息!
【解决方案3】:

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

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

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

【讨论】:

  • 如果是 bitbucket(“克隆”按钮),我在从 ssh://git@<bitbucket-repo>:<port>/dir/to/project.git 删除 ssh:// 时遇到问题,所以要小心,伙计们!
【解决方案4】:

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

所以我不得不设置

client_max_body_size 50m; 

在两个配置文件中:

  • 在 gitlab nginx 网络服务器上(如前面的答案中所述)
  • 还可以在专用服务器上托管的 nginx 反向代理上。

【讨论】:

【解决方案5】:

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

git config --global http.postBuffer 157286400

更多详情请见this

【讨论】:

  • 为我工作!谢谢!
【解决方案6】:

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

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

git push -u origin master

【讨论】:

    【解决方案7】:

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

    你需要增加你的uploadReadAheadSize

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

    1. 扩展服务器字段

    2. 扩展网站

    3. 选择您要修改的网站。

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

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

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

    7. 点击应用

    8. 重启网站

    【讨论】:

    • 重启网站我选择了Default Web Site,在右侧,在Actions下有Stop开始 按钮。
    • 在 IIS 10 中仍需要此修复程序。
    【解决方案8】:

    您使用 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。 现在,您可以愉快地进行推送操作了。

    【讨论】:

      【解决方案9】:

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

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

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

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

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

      【讨论】:

        【解决方案10】:

        当我尝试在 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
        

        【讨论】:

          【解决方案11】:

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

          【讨论】:

            【解决方案12】:

            需要将远程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
            

            希望,这会有所帮助:)

            【讨论】:

              【解决方案13】:

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

              【讨论】:

                【解决方案14】:

                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

                【讨论】:

                • OP 没有询问克隆,而是询问推送。
                • 好吧,OP询问了与github的通信。为什么我回答了一个关于我不知道的要点的答案。
                • 哈,很公平:)
                【解决方案15】:

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

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

                编辑 -

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

                【讨论】:

                  【解决方案16】:

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

                  【讨论】:

                  • 当我执行 git clean 时,它会显示此错误:致命:clean.requireForce 默认为 true,并且既不提供 -i、-n 也不 -f;拒绝打扫
                  • 对于@Chandni 和遇到相同错误消息的任何人,git 会帮助您自己,例如尝试git clean -i 以交互模式启动。
                  • @seethrough - 谢谢
                  【解决方案17】:

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

                  【讨论】:

                    【解决方案18】:

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

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

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

                    【讨论】:

                      猜你喜欢
                      • 1970-01-01
                      • 2014-04-17
                      • 2013-10-27
                      • 2014-05-17
                      • 1970-01-01
                      • 2012-11-07
                      • 2015-06-15
                      • 2012-12-03
                      相关资源
                      最近更新 更多