git clone --depth=1之后拉取其他分支


当项目过大时,git clone会出现超时失败,这时候我们可以只拉去最新的一次或者几次commit:

git clone https://github.com/xxxxxxxx.git --depth=1

这个方法是可以成功把项目 clone 了,但是同时也产生了其他问题-- git branch -a 查看不到其它分支,也切换不了其它分支,因为 .git 记录里面没有其它分支的信息;

解决方法:

git remote set-branches origin remote_branch_name
git fetch --depth 1 origin remote_branch_name
git checkout remote_branch_name


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM