问题描述 git上已经有人建立分支branch170628_foo,希望在本地切换到该分支。但使用git命令切换分支时报错。 $ git checkout branch170628_foo error: pathspec 'branch170628_foo' did not match any file(s) known to git. 12 查看远程分支,发现看不到目标分支。 解决方案 先用fetch命令更新remote索引。 $ git fetch 1 再查看remote分支,发现已经可以看到目标分支branch170628_foo。 $ git branch -a 1 再切换分支: $ git checkout branch170628_foo 或 // 取远程分支并分化一个新分支 $ git checkout -b mybranch origin/mybranch 1234 成功~