当项目过大时,git clone xxxxxx 会很慢,而且是整个项目都克隆到本地。慢还占内存
解决方法很简单,在git clone时加上--depth=1 即可解决 --depth=xxx (xxx: 表示最近几次commit)
depth用于指定克隆深度,为1即表示只克隆最近一次commit.
如果要克隆某个分支+最近的commit 可以这样,
$ git clone --depth 1 https://github.com/xxx/xxxxxxx.git
$ git remote set-branches origin 'remote_branch_name'
$ git fetch --depth 1 origin remote_branch_name
$ git checkout remote_branch_name
如果我只想克隆某个分支呢,这个时候可以这样 single-branch
git clone -b single-branch https://github.com/xxx/xxxxxxx.git
以上这样的整体下载速度还是很可以的,获取到最近的代码,时间也快。
以此记录下~~