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