當項目過大時,git clone時會出現error: RPC failed; HTTP 504 curl 22 The requested URL returned error: 504 Gateway Time-out的問題,如下圖
image.png
解決方法很簡單,在git clone時加上--depth=1即可解決
depth用于指定克隆深度,為1即表示只克隆最近一次commit.
這種方法克隆的項目只包含最近的一次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