git clone --depth=1之后拉取其他分支

当项目过大时,git clone会出现超时失败,这时候我们可以只拉去最新的一次或者几次commit:

git clone --depth=1 xxxxxx

有时候,我们总是图一时之快,而忽略了其他的问题。

你可能很快会发现,拉下来的只是默认的分支,而要想拉取其他分支代码的时候,一脸懵逼,有木有??

其实也很简单:

$ git remote set-branches origin 'remote_branch_name'
$ git fetch --depth 1 origin remote_branch_name
$ git checkout remote_branch_name

搞定收工。

喜欢我的可以关注收藏我的个人博客:Ro.bber

作者:Ro_bber
链接:https://www.jianshu.com/p/1397ce990c58
来源:
著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

你可能感兴趣的:(git clone --depth=1之后拉取其他分支)