当我使用git克隆时,远程终端意外挂起?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (3)
  • 关注 (0)
  • 查看 (681)

我的git客户端在试图克隆存储库一段时间后,重复失败,出现以下错误。

这里有什么问题?

注:我已经向git主机提供商注册了我的ssh密钥。

Receiving objects:  13% (1309/10065), 796.00 KiB | 6 KiB/s
fatal: The remote end hung up unexpectedly
提问于
用户回答回答于

上述任何一项都不适用于我,但以下是我所做的:https://stackoverflow.com/a/22317479

我收到的完整错误消息是:

fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
用户回答回答于

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
用户回答回答于

快速解决方案:

有了这样的错误,我通常首先将postBuffer尺寸按:

git config --global http.postBuffer 524288000

(下面的一些评论报告说,价值必须翻一番):

git config --global http.postBuffer 1048576000

更多信息:

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

Maximum size in bytes of the buffer used by smart HTTP transports when POSTing data to the remote system. For requests larger than this buffer size, HTTP/1.1 and Transfer-Encoding: chunked用于避免在本地创建大型包文件。缺省值为1 MIB,这对于大多数请求来说都足够了。

即使对于克隆,这也会产生效果,在这种情况下,报告:

克隆现在工作很好

注意:如果服务器端出了问题,如果服务器使用Git 2.5+(Q2 2015),错误消息可能会更加明确。

见“Git克隆:远程终止意外挂起,尝试更改postBuffer但仍然失败

库莱(二)在评论中)指出这个亚特兰蒂斯故障排除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

扫码关注云+社区

领取腾讯云代金券