使用背景
比如有人往remote推送了一个新的分支,自己本地没有,但想同步到本地
git switch
- 首先
git branch -r
,找到你需要的那个分支名称 -
origin/HEAD -> origin/master origin/newBranch
git switch newBranch
本地没有这个新分支,git switch
命令会自动创建并跟踪
参考
https://stackoverflow.com/questions/9537392/git-fetch-remote-branch