查看遠程分支:
git branch -a
查看本地分支:
git branch
場景:
假如現在遠程分支有一個:demo
我們本地沒有;
·
·
1.查看遠程分支有哪些:
git branch -a
2.然后切換到這個分支:
git checkout remotes/origin/demo
出來了這么一段話:
$ git checkout remotes/origin/demo
Note: checking out 'remotes/origin/demo'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at 1ad17a6... 演示demo8月12日提交
3.就按照它說的執行:
git checkout -b a
然后就可以了。
·
·
但是,如果執行git pull 會報錯,是因為沒有和遠程分支建立聯系(沒有跟蹤信息)
解決方法:
和遠程分支a建立聯系:
git branch --set-upstream-to=origin/demo
然后就可以了
git pull