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