看不到git远程分支

来源:互联网 发布:批量测试telnet端口 编辑:程序博客网 时间:2024/05/16 04:59

问题描述

git上已经有人建立分支branch170628_foo,希望在本地切换到该分支。但使用git命令切换分支时报错。

$ git checkout branch170628_fooerror: 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或// 取远程分支并分化一个新分支$ git checkout -b mybranch origin/mybranch

成功~