由于公司代码库太大,每次clone代码都会失败,报错如下:
fatal: early EOF
fatal: index-pack failed
这次由于换了电脑,尝试解决了这个问题,借此机会做下记录。(原理暂未研究)
第一步:持续执行以下命令
git config --global core.compression 0
git clone --depth 1 <repo_URI>
git fetch --unshallow
git pull --all
到此已将代码库拉取下来,但是却没有任何分支
第二步:同步远程分支
执行
git config --get remote.origin.fetch
,查看结果是否为+refs/heads/*:refs/remotes/origin/*
,如果不是,则执行git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
若需要拉取dev分支,则执行
git fetch origin dev
获取远程dev分支,然后执行git checkout -b dev origin/dev
来建立分支
参考:https://stackoverflow.com/questions/21277806/fatal-early-eof-fatal-index-pack-failed