1. 切換git遠程分支,使用命令:git checkout -b 分支名稱。 git
則會致使以下錯誤提示:服務器
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>
這時候再使用git branch 命令查看本地分支,就會發現當前分支是在一個 叫「(HEAD detached at 遠程分支名)」上。detached是遊離的意思,表名當前分支是在遊離狀態。 fetch
2. 遠程服務器新建了分支,本地沒法checkout ,或者本地看不到,使用命令: git branch -r 能夠查看遠程分支。this
若是這時候直接使用 git checkout -b xxxx 去切換到遠程分支,是會報以下錯誤的
spa
error: pathspec 'branch170628_foo' did not match any file(s) known to git
請使用命令:git fetch 更新remote索引code
取回全部分支(branch)的更新。若是隻想取回特定分支的更新,能夠指定分支名,例:$ git fetch <遠程主機名> <分支名> orm