版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
码云上,由于提交的版本历史记录过多,即长期以来,提交了成百上千个版本,导致仓库存储很大,超过了1G,直接clone会报错:
fatal: early EOF
fatal: the remote end hung up unexpectedly
fatal: index-pack failed
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
git仓库某个分支历史版本过多,占用的存储也相应增大,会造成git客户端在clone或者checkout时失败。解决方法是clone或者checkout时设置一下拉取的深度(depth)。
clone项目:
将项目的Head版本clone下来:
$ git clone --depth 1 仓库地址
depth 1的作用是拉取的版本深度为1,即拉取最近一次提交的版本。这时候你可以看下clone下来的Head版本指向了哪个分支,查看当前已拉取的所有分支:
$ git branch -a
checkout其它分支:
通过分支名称去拉取其它分支。依次执行如下指令:
$ git remote set-branches origin '远程分支名称'
$ git fetch --depth 1 origin 远程分支名称
fetch --depth 1的作用是拉取该分支的版本深度为1,同理,也是拉取最近一次提交的版本。值也可以改为其他的,比如想拉取最近10次提交的版本历史,则–depth 10这样子。