场景:git远程新建分支,在本地开发工具中(如vscode)切换远程新建的分支时,提示不存在当前分支,如下图:
1、此时需要同步下远程的分支,采用如下命令:
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
将会同步远程的所有分支到本地。
本地不存在的会直接同步成功,本地已经存在的分支会提示已经存在。
2、更新键入时看到的列表
git fetch --all将更新您键入时看到的列表
完成更新分支~