参考:https://stackoverflow.com/questions/23708231/git-shallow-clone-clone-depth-misses-remote-branches
1. 执行
git remote set-branches origin '*'
2. fetch从远程拉取分支
git fetch
3. 切换到分支
git checkout -t origin/<branch_name>
原理:
打开shallow clone的.git/config,会看到一下一行:
fetch = +refs/heads/master:refs/remotes/origin/master
指定fetch的时候只更新master分支
调用remote set-branches后,该设置变成:
fetch = +refs/heads/*:refs/remotes/origin/*
即获取所有分支
网友评论