當項目過大時,git clone時會出現error: RPC failed; HTTP curl The requested URL returned error: Gateway Time-out的問題
解決方法很簡單,在git clone時加上--depth=1即可解決
克隆的項目只包含最近的一次commit的一個分支,體積很小,即可解決文章開頭提到的項目過大導致Timeout的問題,但會產生另外一個問題,他只會把默認分支clone下來,其他遠程分支并不在本地,所以這種情況下,需要用如下方法拉取其他分支:
$ git clone --depth=1??https://github.com/dogescript/xxxxxxx.git
$ git remote set-branches origin 'remote_branch_name'
$ git fetch --depth=1??origin remote_branch_name
$ git checkout remote_branch_name
解決
第一步:克隆深度設置為1
git clone 倉庫地址 --depth 1
cd 項目根目錄
第二部:拉去當前完整分支
git fetch --unshallow ?
//這一步完成相當于“git clone -b 分支 倉庫地址”,但項目實在太大,克隆一個分支也是失敗,個人潔癖,又喜歡把所有分支克隆到本地,如有需要繼續下一步,否則這一步完成可以正常開發的。
第三步:跟蹤所有其他遠程分支
git remote set-branches origin '*'
第四步:拉去所有遠程分支
git fetch -v
參考地址:https://www.jianshu.com/p/cf6933e8f218
? ? ? ? ? ? ? ? ? https://www.jianshu.com/p/4b669dee03a7