問題描述
git上已經有人建立分支branch170628_foo,希望在本地切換到該分支。但使用git命令切換分支時報錯。
$ git checkout branch170628_foo
error: pathspec 'branch170628_foo' did not match any file(s) known to git.
查看遠程分支,發現看不到目標分支。
解決方案
先用fetch命令更新remote索引。
$ git fetch
再查看remote分支,發現已經可以看到目標分支branch170628_foo。
$ git branch -a
再切換分支:
$ git checkout branch170628_foo
成功~