git cloning 远程端意外挂断
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6842687/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The remote end hung up unexpectedly while git cloning
提问by Joe
My git
client repeatedly fails with the following error after trying to clone the repository for some time.
git
在尝试克隆存储库一段时间后,我的客户端反复失败并出现以下错误。
What could be the issue here?
这里可能是什么问题?
Note:I have registered my SSH key with the GIT hosting provider
注意:我已经在 GIT 托管服务提供商处注册了我的 SSH 密钥
Receiving objects: 13% (1309/10065), 796.00 KiB | 6 KiB/s
fatal: The remote end hung up unexpectedly
回答by VonC
Quick solution:
快速解决方案:
With this kind of error, I usually start by raising the postBuffer
size by:
对于这种错误,我通常首先通过以下方式增加postBuffer
大小:
git config --global http.postBuffer 524288000
(some comments below report having to double the value):
(下面的一些评论报告必须将价值加倍):
git config --global http.postBuffer 1048576000
More information:
更多信息:
From the git config
man page, http.postBuffer
is about:
从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 andTransfer-Encoding: chunked
is used to avoid creating a massive pack file locally. Default is 1 MiB, which is sufficient for most requests.
将数据发布到远程系统时,智能 HTTP 传输使用的缓冲区的最大大小(以字节为单位)。
对于大于此缓冲区大小的请求,HTTP/1.1Transfer-Encoding: chunked
用于避免在本地创建大量包文件。默认为 1 MiB,对于大多数请求来说已经足够了。
Even for the clone, that can have an effect, and in this instance, the OP Joereports:
即使对于克隆,这也会产生影响,在这种情况下,OP Joe报告:
[clone] works fine now
[克隆] 现在工作正常
Note: if something went wrong on the server side, and if the server uses Git 2.5+ (Q2 2015), the error message might be more explicit.
See "Git cloning: remote end hung up unexpectedly, tried changing postBuffer
but still failing".
注意:如果服务器端出现问题,并且服务器使用 Git 2.5+(2015 年第二季度),则错误消息可能更明确。
请参阅“ Git 克隆:远程端意外挂断,尝试更改postBuffer
但仍然失败”。
Kulai(in the comments) points out to this Atlassian Troubleshooting Git page, which adds:
Kulai(在评论中)指出了这个 Atlassian 故障排除 Git 页面,其中补充说:
Error code 56
indicates a curl receive the error ofCURLE_RECV_ERROR
which means there was some issue that prevented the data from being received during the cloning process.
Typically this is caused by a network setting, firewall, VPN client, or anti-virus that is terminating the connection before all data has been transferred.
Error code 56
表示 curl 收到错误,CURLE_RECV_ERROR
这意味着在克隆过程中存在一些阻止数据接收的问题。
这通常是由网络设置、防火墙、VPN 客户端或防病毒软件在传输所有数据之前终止连接造成的。
It also mentions the following environment variable, order to help with the debugging process.
它还提到了以下环境变量,以帮助调试过程。
# 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
With Git 2.25.1 (Feb. 2020), you know more about this http.postBuffer
"solution".
使用 Git 2.25.1(2020 年 2 月),您对这个http.postBuffer
“解决方案”有了更多的了解。
See commit 7a2dc95, commit 1b13e90(22 Jan 2020) by brian m. carlson (bk2204
).
(Merged by Junio C Hamano -- gitster
--in commit 53a8329, 30 Jan 2020)
(Git Mailing list discussion)
请参阅brian m 的commit 7a2dc95和commit 1b13e90(2020 年 1 月 22 日)。卡尔森 ( bk2204
)。
(由Junio C gitster
Hamano合并-- --in commit 53a8329,2020年 1 月 30 日)
(Git 邮件列表讨论)
docs
: mention when increasing http.postBuffer is valuableSigned-off-by: brian m. carlson
Users in a wide variety of situations find themselves with HTTP push problems.
Oftentimes these issues are due to antivirus software, filtering proxies, or other man-in-the-middle situations; other times, they are due to simple unreliability of the network.
However, a common solution to HTTP push problems found online is to increase http.postBuffer.
This works for none of the aforementioned situations and is only useful in a small, highly restricted number of cases: essentially, when the connection does not properly support HTTP/1.1.
Document when raising this value is appropriate and what it actually does, and discourage people from using it as a general solution for push problems, since it is not effective there.
docs
: 当增加 http.postBuffer 有价值时提及签字人:brian m. 卡尔森
用户在各种情况下都会发现 HTTP 推送问题。
通常,这些问题是由防病毒软件、过滤代理或其他中间人情况引起的;其他时候,它们是由于网络的简单不可靠性。
但是,网上发现的HTTP推送问题的一个常见解决方案是增加http.postBuffer。
这对上述任何一种情况都不起作用,并且仅在少数情况下有用:基本上,当连接不正确支持 HTTP/1.1 时。
记录何时提高此值是合适的以及它实际做什么,并阻止人们将其用作推送问题的通用解决方案,因为它在那里无效。
So the documentation for git config http.postBuffer
now includes:
所以git config http.postBuffer
现在的文档包括:
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 is used to avoid creating a massive pack file locally.
Default is 1 MiB, which issufficient for most requests.Note that raising this limit is only effective for disabling chunked transfer encoding and therefore should be used only where the remote server or a proxy only supports HTTP/1.0 or is noncompliant with the HTTP standard.
Raising this is not, in general, an effective solution for most push problems, but can increase memory consumption significantly since the entire buffer is allocated even for small pushes.
http.postBuffer
将数据发布到远程系统时,智能 HTTP 传输使用的缓冲区的最大大小(以字节为单位)。
对于大于此缓冲区大小的请求,HTTP/1.1 和 Transfer-Encoding: chunked 用于避免在本地创建大量打包文件。
默认值为 1 MiB,这足以满足大多数请求。请注意,提高此限制仅对禁用分块传输编码有效,因此应仅在远程服务器或代理仅支持 HTTP/1.0 或不符合 HTTP 标准的情况下使用。
对于大多数推送问题,提高这个通常不是一个有效的解决方案,但会显着增加内存消耗,因为即使是小推送也分配了整个缓冲区。
回答by wizawu
Same error with Bitbucket. Fixed by
与 Bitbucket 相同的错误。固定由
git config --global http.postBuffer 500M
git config --global http.maxRequestBuffer 100M
git config --global core.compression 0
回答by Kurtis
The http.postBuffer trick did notwork for me. However:
该http.postBuffer招确实不适合我的工作。然而:
For others experiencing this problem, it may be an issue with GnuTLS. If you set Verbose mode, you may see the underlying error look something along the lines of the code below.
对于遇到此问题的其他人,这可能是 GnuTLS 的问题。如果您设置详细模式,您可能会看到与下面代码行类似的潜在错误。
Unfortunately, my only solution so far is to use SSH.
不幸的是,到目前为止,我唯一的解决方案是使用 SSH。
I've seen a solution posted elsewhereto compile Git with OpenSSL instead of GnuTLS. There is an active bug report for the issue here.
我在别处看到过一个解决方案,用 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
回答by Ruxandra T.
Obs.: Changing http.postBuffer
might also require to set up the Nginx configuration file for gitlab to accept larger body sizes for the client, by tuning the value of client_max_body_size.
观察:更改http.postBuffer
可能还需要通过调整 client_max_body_size 的值,为 gitlab 设置 Nginx 配置文件以接受客户端更大的主体尺寸。
However, there is a workaround if you have access to the Gitlab machineor to a machine in its network, and that is by making use of git bundle
.
但是,如果您有权访问 Gitlab 机器或其网络中的机器,则有一种解决方法,那就是使用git bundle
.
- go to your git repository on the source machine
- run
git bundle create my-repo.bundle --all
- transfer (eg., with rsync) the my-repo.bundle file to the destination machine
- on the destination machine, run
git clone my-repo.bundle
git remote set-url origin "path/to/your/repo.git"
git push
- 转到源计算机上的 git 存储库
- 跑
git bundle create my-repo.bundle --all
- 将 my-repo.bundle 文件传输(例如,使用 rsync)到目标机器
- 在目标机器上,运行
git clone my-repo.bundle
git remote set-url origin "path/to/your/repo.git"
git push
All the best!
祝一切顺利!
回答by Ayan
The only thing that worked for me was to clone the repo using the HTTPSlink instead of the SSHlink.
唯一对我有用的是使用HTTPS链接而不是SSH链接克隆存储库。
回答by Aransiola Oluwaseun
If you are using https and you are getting the error.
如果您正在使用 https 并且您收到错误。
I used https instead of http and it solved my problem
我使用 https 而不是 http,它解决了我的问题
git config --global https.postBuffer 524288000
回答by Андрей Саяпин
Based on this answer, I tried following (with https url):
基于这个答案,我尝试了以下(使用 https url):
- initial cloning of repo:
- repo 的初始克隆:
git clone --depth 25 url-here
git clone --depth 25 url-here
- fetch commits with increasing twice per try depth:
- 每次尝试深度增加两次获取提交:
git fetch --depth 50
git fetch --depth 50
git fetch --depth 100
git fetch --depth 100
git fetch --depth 200
git fetch --depth 200
...and so on
...等等
- eventually (when I think enough is fetched) I run
git fetch --unshallow
- and it's done.
- 最终(当我认为获取了足够多的内容时)我运行了
git fetch --unshallow
- 并且完成了。
The process obviously takes much more time, but in my case setting http.postBuffer
and core.compression
didn't help.
这个过程显然需要更多的时间,但在我的情况下设置http.postBuffer
并core.compression
没有帮助。
UPD: I found out that fetching via sshworks for any repo size (discovered accidentally), done with git clone <ssh url>
, given you have created ssh keys. Once repo is fetched, I change remote address using git remote set-url <https url to repo>
UPD:我发现通过ssh获取适用于任何存储库大小(意外发现),使用 完成git clone <ssh url>
,因为您已经创建了 ssh 密钥。获取 repo 后,我使用以下命令更改远程地址git remote set-url <https url to repo>
回答by G Gopikrishna
I got the same issue, I fixed this with trial and error method. I changed the core.compression value until it works.
我遇到了同样的问题,我用试错法解决了这个问题。我更改了 core.compression 值,直到它起作用为止。
I started with "git config --global core.compression 1" after 3 attempts
3 次尝试后,我从“git config --global core.compression 1”开始
"git config --global core.compression 4" worked for me.
“git config --global core.compression 4”对我有用。
回答by Srikanth Josyula
This is due the internet connectivity issue, i faced the same issue. I did a shallow copy of code using
这是由于互联网连接问题,我遇到了同样的问题。我做了一个浅拷贝的代码使用
git clone --depth 1 //FORKLOCATION
Later unshallowed the clone using
后来使用
git fetch --unshallow
回答by hmjha
I got solution after using below command:
使用以下命令后我得到了解决方案:
git repack -a -f -d --window=250 --depth=250
git repack -a -f -d --window=250 --depth=250