当git克隆时,远程端意外挂断

Joe*_*Joe 253 git

git尝试克隆存储库一段时间后,我的客户端一再失败并出现以下错误.

这可能是什么问题?

注意:我已经向GIT托管服务提供商注册了我的SSH密钥

Receiving objects:  13% (1309/10065), 796.00 KiB | 6 KiB/s
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

Von*_*onC 426

快速解决方案

有了这种错误,我通常首先提高postBuffer尺寸:

git config --global http.postBuffer 524288000
Run Code Online (Sandbox Code Playgroud)

(以下一些评论报告不得不加倍价值):

git config --global http.postBuffer 1048576000
Run Code Online (Sandbox Code Playgroud)

更多信息:

git config手册页,http.postBuffer是关于:

将数据发送到远程系统时,智能HTTP传输使用的缓冲区的最大大小(以字节为单位).
对于大于此缓冲区大小的请求,HTTP/1.1 Transfer-Encoding: chunked用于避免在本地创建大量包文件.默认值为1 MiB,足以满足大多数请求.

即使是克隆,也会产生影响,在这种情况下,OP Joe会报告:

[克隆]现在工作正常


注意:如果服务器端出现问题,并且服务器使用Git 2.5+(2015年第2季度),则错误消息可能更明确.
请参阅" Git克隆:远程端意外挂断,尝试更改postBuffer但仍然失败 ".


Kulai(在评论中)指出这个Atlassian Troubleshooting Git页面,它增加了:

Error code 56表示卷曲接收错误,CURLE_RECV_ERROR这意味着存在一些阻止在克隆过程中接收数据的问题.
通常,这是由网络设置,防火墙,VPN客户端或在传输所有数据之前终止连接的防病毒引起的.

它还提到了以下环境变量,以帮助调试过程.

# Linux
export GIT_TRACE_PACKET=1
export GIT_TRACE=1
export GIT_CURL_VERBOSE=1

#Windows
set GIT_TRACE_PACKET=1
set GIT_TRACE=1
set GIT_CURL_VERBOSE=1
Run Code Online (Sandbox Code Playgroud)

  • 也许文档是错误的,但POST不是通过HTTP获取/克隆时发生的情况.我很困惑为什么`postBuffer`设置在克隆或提取中有任何影响. (7认同)
  • 谢谢你的诀窍,但答案的价值是它的两倍. (4认同)
  • 注意:在提升 postBuffer 时,我遇到了“npmpublish”的几个问题。当我将其设置为“50000000”时,问题就消失了。顺便说一下,默认值是“1000000”。 (3认同)
  • 这对我来说也很有用,但是对于什么时候"智能HTTP传输"涉及到`ssh://`的传输有点困惑. (2认同)
  • @Astravagrant好,我已经更新了答案,以使该值更加可见。 (2认同)

wiz*_*awu 18

与Bitbucket相同的错误.固定的

git config --global http.postBuffer 500M
git config --global http.maxRequestBuffer 100M
git config --global core.compression 0
Run Code Online (Sandbox Code Playgroud)


Kur*_*tis 17

该http.postBuffer伎俩并没有为我工作.然而:

对于遇到此问题的其他人,可能是GnuTLS的问题.如果您设置了详细模式,您可能会看到基础错误看起来像下面的代码行.

不幸的是,到目前为止我唯一的解决方案是使用SSH.

我已经看到在其他地方发布的解决方案,用OpenSSL而不是GnuTLS编译Git.没有为这个问题的主动漏洞报告在这里.

GIT_CURL_VERBOSE=1 git clone https://github.com/django/django.git

Cloning into 'django'...
* Couldn't find host github.com in the .netrc file; using defaults
* About to connect() to github.com port 443 (#0)
*   Trying 192.30.252.131... * Connected to github.com (192.30.252.131) port 443 (#0)
* found 153 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: 
*    start date: Mon, 10 Jun 2013 00:00:00 GMT
*    expire date: Wed, 02 Sep 2015 12:00:00 GMT
*    issuer: C=US,O=DigiCert Inc,OU=www.digicert.com,CN=DigiCert High Assurance EV CA-1
*    compression: NULL
*    cipher: ARCFOUR-128
*    MAC: SHA1
> GET /django/django.git/info/refs?service=git-upload-pack HTTP/1.1
User-Agent: git/1.8.4
Host: github.com
Accept: */*
Accept-Encoding: gzip

Pragma: no-cache
< HTTP/1.1 200 OK
< Server: GitHub.com
< Date: Thu, 10 Oct 2013 03:28:14 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 github.com left intact
* Couldn't find host github.com in the .netrc file; using defaults
* About to connect() to github.com port 443 (#0)
*   Trying 192.30.252.131... * connected
* found 153 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: 
*    start date: Mon, 10 Jun 2013 00:00:00 GMT
*    expire date: Wed, 02 Sep 2015 12:00:00 GMT
*    issuer: C=US,O=DigiCert Inc,OU=www.digicert.com,CN=DigiCert High Assurance EV CA-1
*    compression: NULL
*    cipher: ARCFOUR-128
*    MAC: SHA1
> POST /django/django.git/git-upload-pack HTTP/1.1
User-Agent: git/1.8.4
Host: github.com
Accept-Encoding: gzip

Content-Type: application/x-git-upload-pack-request
Accept: application/x-git-upload-pack-result
Content-Encoding: gzip
Content-Length: 2299
* upload completely sent off: 2299out of 2299 bytes

< HTTP/1.1 200 OK
< Server: GitHub.com
< Date: Thu, 10 Oct 2013 03:28:15 GMT

< Content-Type: application/x-git-upload-pack-result
< 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
< 
remote: Counting objects: 232015, done.
remote: Compressing objects: 100% (65437/65437), done.
* GnuTLS recv error (-9): A TLS packet with unexpected length was received.
* Closing connection #0
error: RPC failed; result=56, HTTP code = 200
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
Run Code Online (Sandbox Code Playgroud)

  • 我得到像你一样的详细日志.但通过使用更大的postBuffer值解决. (3认同)
  • git config --global http.postBuffer 10000000000000000000000000000000 (3认同)
  • 较新的 git 版本由于“致命:‘http.postbuffer’的错误数字配置值‘100000000000’:超出范围”而失败,但设置配置值对我的情况没有帮助。 (2认同)

Анд*_*пин 12

基于这个答案,我尝试了以下(使用 https url):

  1. repo 的初始克隆:

git clone --depth 25 url-here

  1. 每次尝试深度增加两次获取提交:

git fetch --depth 50

git fetch --depth 100

git fetch --depth 200

...等等

  1. 最终(当我认为获取了足够多的内容时)我运行了git fetch --unshallow- 并且完成了。

这个过程显然需要更多的时间,但在我的情况下设置http.postBuffercore.compression没有帮助。

UPD:我发现通过ssh获取适用于任何存储库大小(意外发现),使用 完成git clone <ssh url>,因为您已经创建了 ssh 密钥。获取 repo 后,我使用以下命令更改远程地址git remote set-url <https url to repo>


Aya*_*yan 10

唯一对我有用的是使用HTTPS链接而不是SSH链接克隆存储库。


Rux*_* T. 7

Obs.:更改http.postBuffer可能还需要为gitlab设置Nginx配置文件,以通过调整client_max_body_size的值来接受客户端更大的主体大小.

但是,如果您可以访问Gitlab计算机或其网络中的计算机,则可以使用git bundle.

  1. 转到源计算机上的git存储库
  2. git bundle create my-repo.bundle --all
  3. 将my-repo.bundle文件传输(例如,使用rsync)到目标计算机
  4. 在目标计算机上运行 git clone my-repo.bundle
  5. git remote set-url origin "path/to/your/repo.git"
  6. git push

祝一切顺利!


小智 7

如果您正在使用 https 并且您收到错误。

我使用 https 而不是 http,它解决了我的问题

git config --global https.postBuffer 524288000
Run Code Online (Sandbox Code Playgroud)


hmj*_*jha 6

使用以下命令后我得到了解决方案:

git repack -a -f -d --window=250 --depth=250

  • 当 clone 尚未创建本地 git 存储库时,您将如何运行它? (6认同)

Sri*_*ula 6

这是由于互联网连接问题,我遇到了同样的问题。我做了一个浅拷贝的代码使用

git clone --depth 1 //FORKLOCATION
Run Code Online (Sandbox Code Playgroud)

后来使用

git fetch --unshallow
Run Code Online (Sandbox Code Playgroud)


Saz*_*han 6

对于共享带宽,尝试在负载较小时进行克隆。否则,请尝试使用高速连接。如果还是不行,请使用下面的命令,

git config --global http.postBuffer 2048M
git config --global http.maxRequestBuffer 1024M
git config --global core.compression 9

git config --global ssh.postBuffer 2048M
git config --global ssh.maxRequestBuffer 1024M

git config --global pack.windowMemory 256m 
git config --global pack.packSizeLimit 256m
Run Code Online (Sandbox Code Playgroud)

并再次尝试克隆。您可能需要根据可用内存大小更改这些设置。


小智 5

我遇到了同样的问题,我用试错法解决了这个问题。我更改了 core.compression 值,直到它起作用为止。

3 次尝试后,我从“git config --global core.compression 1”开始

“git config --global core.compression 4”对我有用。


归档时间:

查看次数:

296062 次

最近记录:

6 年,2 月 前