赞
踩
https://www.jianshu.com/p/1031dd2a6c3a
当项目过大时,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
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。