今天在电脑上git clone 远程仓库,出现如下错误:

git clone http://IP:端口/axxxx/axxxxre-dxxxxx-repository.git
Cloning into 'xxxxx'...
remote: Enumerating objects: 2190, 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

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

google后,发现原因是远程仓库过大。

解决方法如下:

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

先做一层浅拷贝,再做深拷贝,即可解决。

但是这种方法拉取的代码只能更新和push,它无法查看远程分支,比如说你默认拉的master分支,此时你的远程仓库还有n个分支,但是你本地用电脑只能查看你当前的master分支,针对于这种问题,需要修改config配置文件:

进入项目根文件夹,修改 .git 隐藏文件夹目录中 config文件

fetch = +refs/heads/master:refs/remotes/origin/master

修改为

fetch = +refs/heads/*:refs/remotes/origin/*

然后再次拉取代码

git pull origin

source:StackOverflow

最后修改:2021 年 07 月 21 日 09 : 52 AM
如果觉得我的文章对你有用,请随意赞赏