对于一个有很多提交的项目,加参数–depth 1,可以只拉取最近一次提交,减小clone体积,加快clone速度,解决下载Timeout的问题

git clone --depth 1

depth用于指定克隆深度,为1即表示只克隆最近一次commit.

只会把默认分支clone下来,其他远程分支并不在本地,所以这种情况下,需要用如下方法拉取其他分支

$ git clone --depth 1 https://xxxx.git
$ git remote set-branches origin 'remote_branch_name'
$ git fetch --depth 1 origin remote_branch_name
$ git checkout remote_branch_name
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐