当我试图从GitLab (GitLab 6.6.2 4ef8369)克隆一个存储库时,我遇到了这个错误:

remote: Counting objects: 66352, done.
remote: Compressing objects: 100% (10417/10417), done.
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

然后中止克隆。我该如何避免这种情况?


当前回答

这种情况的发生通常是由于以下原因之一:

缓慢的互联网。

切换到网络连接稳定的局域网电缆在很多情况下都有帮助。在获取时避免执行任何并行网络密集型任务。

服务器端TCP/IP连接超时。

你也无能为力。您所能做的就是请求系统管理员或CI/CD团队增加etcp /IP超时时间并等待。

服务器负载过重。

由于工作时间服务器负载过重,下载大文件可能会不断失败。晚上开始下载后离开你的机器。

客户端机器上的小HTTPS缓冲区。

增加post和request的缓冲区大小可能会有所帮助,但不能保证

Git配置——global http。postBuffer 524288000 Git配置——global http。maxRequestBuffer 524288000 Git配置——global core.compression 0

其他回答

几天后,今天我才解决了这个问题。按照本文生成ssh密钥:

https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/

申报给

Git提供者(我正在使用的GitLab, GitHub)。 将此添加到本地标识。

然后通过命令克隆:

git clone username@mydomain.com:my_group/my_repository.git

没有错误发生。

上述问题

RPC失败;Curl 18传输关闭,读取数据出色 剩下的

因为通过HTTP协议克隆时出现错误(curl命令)。

并且,你应该增加缓冲区大小:

git config --global http.postBuffer 524288000

我在这里试了所有的答案。 我在试着往我的机器里添加椰荚。

我没有SSH密钥,所以谢谢@Do Nhu Vy

https://stackoverflow.com/a/38703069/2481602

最后使用

git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master

最终修复问题找到https://stackoverflow.com/a/50959034/2481602

这种情况经常发生,我的网络连接很慢,我不得不克隆一个相当大的git存储库。最常见的问题是连接关闭,整个克隆被取消。

Cloning into 'large-repository'...
remote: Counting objects: 20248, done.
remote: Compressing objects: 100% (10204/10204), done.
error: RPC failed; curl 18 transfer closed with outstanding read data remaining 
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

经过大量的尝试和错误,以及大量的“远程端意外挂断”之后,我有了一个适合我的方法。这个想法是先做一个浅克隆,然后用它的历史更新存储库。

$ git clone http://github.com/large-repository --depth 1
$ cd large-repository
$ git fetch --unshallow

下面这些步骤对我很有用:

cd [dir]
git init
git clone [your Repository Url]

我希望这对你也有用。

当我尝试从远程克隆时,反复出现同样的问题:

remote: Counting objects: 182, done.
remote: Compressing objects: 100% (149/149), done.
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

最后这招对我有用:

git clone https://username@bitbucket.org/repositoryName.git --depth 1