我的 git
客户端在尝试克隆存储库一段时间后,反复出现以下错误。
这里可能出了什么问题?
注意:我已经将我的 SSH 密钥注册到了 GIT 托管提供商。
Receiving objects: 13% (1309/10065), 796.00 KiB | 6 KiB/s
fatal: The remote end hung up unexpectedly
我的 git
客户端在尝试克隆存储库一段时间后,反复出现以下错误。
这里可能出了什么问题?
注意:我已经将我的 SSH 密钥注册到了 GIT 托管提供商。
Receiving objects: 13% (1309/10065), 796.00 KiB | 6 KiB/s
fatal: The remote end hung up unexpectedly
对于这种错误,我通常会通过增加postBuffer
的大小来解决:
git config --global http.postBuffer 524288000
git config --global http.postBuffer 1048576000
postBuffer
但仍然失败”。
Kulai (在评论中) 指出了 这个 Atlassian Git 故障排除页面, 它补充道:
错误代码 56
表示 curl 接收到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
http.postBuffer
的“解决方案”。bk2204
)完成。gitster
--合并于提交 53a8329,2020年1月30日)docs
:提到增加http.postBuffer的价值签名:brian m. carlson
在各种情况下,用户都会遇到HTTP推送问题。
通常,这些问题是由于防病毒软件、过滤代理或其他中间人攻击等原因引起的;而有时,它们是由于网络的不可靠性导致的。
然而,在网上找到的解决HTTP推送问题的常见方法是增加http.postBuffer。
这对于前述情况都没有作用,只在一小部分高度受限的情况下才有用,即当连接不正确支持HTTP/1.1时。
记录何时适合提高此值以及其实际作用,并劝阻人们将其作为推送问题的通用解决方案使用,因为它在那里并不有效。
所以现在git config http.postBuffer
的文档包括:
使用智能HTTP传输进行POST数据到远程系统时,缓冲区的最大字节数。 对于大于此缓冲区大小的请求,将使用HTTP/1.1和Transfer-Encoding: chunked来避免在本地创建庞大的打包文件。 默认为1 MiB,对大多数请求来说足够。
http.postBuffer
ssh://
进行传输时何时涉及“智能HTTP传输”。 - CodeClown42npm publish
时遇到了几个问题。当我将其设置为50000000
时,问题消失了。默认值是1000000
。 - Martin Braun在Bitbucket上出现了相同的错误。通过修复
git config --global http.postBuffer 500M
git config --global http.maxRequestBuffer 100M
git config --global core.compression 0
http.postBuffer并没有为我解决问题,然而:
对于其他遇到此问题的人来说,可能是GnuTLS引起了问题。如果你设置了详细模式,你可能会看到底层错误信息类似于以下代码。
不幸的是,目前我的唯一解决方案就是使用SSH。
我在其他地方看到了一个解决方案,即通过OpenSSL编译Git而不是GnuTLS。这个问题有一个活跃的bug报告 在这里。
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
100000000000000
。 - nhoxbypass参考这个回答,我尝试了以下步骤(使用 https url):
git clone --depth 25 url-here
git fetch --depth 50
git fetch --depth 100
git fetch --depth 200
......以此类推
git fetch --unshallow
命令 - 完成操作。这个过程显然需要更多时间,但在我的情况下设置 http.postBuffer
和 core.compression
并没有帮助。
更新:我发现通过ssh拉取可以适用于任何仓库大小(偶然发现的),使用命令 git clone <ssh url>
,前提是你已经创建了 ssh 密钥。一旦仓库被获取,我会使用 git remote set-url <https url to repo>
命令改变远程地址。
在带宽共享情况下,尝试在负载较少时进行克隆。否则,请使用高速连接再次尝试。如果仍无法解决问题,请使用以下命令:
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
再次尝试克隆。您可能需要根据可用内存大小更改这些设置。
对我而言唯一有效的方法是使用HTTPS链接而不是SSH链接克隆仓库。
这是由于互联网连接问题导致的,我也遇到了同样的问题。 我使用浅复制代码。
git clone --depth 1 //FORKLOCATION
稍后使用未被禁止的方法卸载克隆。
git fetch --unshallow
http.postBuffer
可能还需要设置Nginx配置文件以便gitlab接受客户端更大的请求体大小,可以通过调整client_max_body_size的值来实现。
但是,如果您可以访问Gitlab机器或其网络中的一台机器,则有一个变通方法,即利用git bundle
。
git bundle create my-repo.bundle --all
git clone my-repo.bundle
git remote set-url origin "path/to/your/repo.git"
git push
git config --global https.postBuffer 524288000
git repack -a -f -d --window=250 --depth=250
git push origin main
终于成功了。谢谢。 - Osama Mohammed
git config --global http.postBuffer 524288000
对您的克隆操作是否有任何影响?是否有额外的错误信息,比如 "error: RPC failed; result=56, HTTP code = 0
"? - VonCgit config --global http.postBuffer 524288000
命令后进行克隆吗? - VonCssh
而不是https
。 - Buzut