因為項目太大,然后直接git clone
拉不下來代碼
會報error: RPC failed; HTTP 504 curl 22 The requested URL returned error: 504 Gateway Time-out
或者類似的錯誤
然后就加參數用git clone --depth=10 https://xxx.xxx/xxx.git
拉下來了
depth用於指定克隆深度,為10即表示只克隆最近十次commit.
執行完后,項目是拉下來了,但是使用git branch -a
查看分支的時候看不到其他遠程分支
解決辦法:
git remote set-branches --add origin [分支名稱]
git fetch origin [分支名稱]
git checkout [分支名稱]
然后再用git branch -a
查看就能看到相應遠程分支了
參考資料:https://stackoverflow.com/questions/23708231/git-shallow-clone-clone-depth-misses-remote-branches
后續補充:
可修改.git/config
文件
將remote
塊下面的fetch = +refs/heads/master:refs/remotes/origin/master
或者類似配置修改為fetch = +refs/heads/*:refs/remotes/origin/*
有多條fetch
配置時刪除其他配置
然后執行git fetch -v
即可獲取到完整分支信息
參考資料2:https://segmentfault.com/q/1010000000409170
更新遠程分支信息到本地
git fetch origin --prune
# 二選一即可
git remote prune origin