Git checkout别人的分支error

在dev分支执行切换分支命令,失败。之前没有切到过这个分支。

原因是,别人在远端新建的分支,需要fetch拉取同步远端所有的分支才可以。(虽然我本地dev分支有fetch->merge,但这两个操作应该不一样。 // 如有理解错误,请评论指出,谢谢!)

PS E:codedevelopproject> git checkout other-branchB
error: pathspec 'other-branchB' did not match any file(s) known to git

解决办法:

1)在dev分支:git branch -a  //查看所有分支列表,看到打印出

other-branchA // 以前切换成功的分支,也是别人的分支
* dev   // 当前分支
remotes/origin/other-branchB// 远端分支

2)git fetch // 拉取所有远端分支,看到打印出

 * [new branch]      other-branchB         -> origin/other-branchB

3)  git checkout other-branchB //开始切换分支,看到下面的就是切换成功了

Switched to a new branch 'other-branchB'
Branch 'other-branchB' set up to track remote branch 'other-branchB' from 'origin'.

原文地址:https://www.cnblogs.com/xxiaonian/p/14610843.html