git clone 失败
仓库历史悠久,代码提交历史过多导致拉取失败
只拉取一层代码
–depth:限制代码clone深度
1:最近一次commit
git clone --depth 1 https://github.com/XXX
clone --depth 1后拉取其它指定分支
使用git clone --depth 1拉取仓库代码后,git branch -a查看远程分支只有master并没有其它分支信息,如果需要获取远程的某个分支,操作如下
// 在本地生命远程名为dev的分支
git remote set-branches origin 'develop'
// 同步远程该分支信息
git fetch --depth 1 origin develop
// 切换至dev分支
git checkout develop
clone --depth 1后拉取剩余全部分支
git 官方文档有提供 unshallow 参数能够将远程当前分支之前的commit记录及其它分支信息都同步至本地,实战就交给大家啦,预测会超级慢
官方解释
git pull --unshallow