无法切换到' Remote Branch' - 头部独立

时间:2017-06-28 10:24:11

标签: git github gitlab

无法切换到' Remote Branch' - 头部独立

GitBash的输出(下面列出;列出远程分支,总共两个:主和主干):

  [Laptop1 ~/Desktop/User1 (master)]$ git branch -a
* master
  remotes/master/master
  remotes/master/trunk
  remotes/origin/master
  remotes/origin/trunk
[Laptop1 ~/Desktop/User1 (master)]$ git checkout remotes/master/master
Note: checking out 'remotes/master/master'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at 57df590... Third coommit...
[Laptop1 ~/Desktop/User1 ((57df590...))]$ git branch -a
* (HEAD detached at master/master)
  master
  remotes/master/master
  remotes/master/trunk
  remotes/origin/master
  remotes/origin/trunk
[Laptop1 ~/Desktop/User1 ((57df590...))]$

1 个答案:

答案 0 :(得分:0)

信息消息说明了一切:调用git checkout -b remote-master remotes/master/master。这将从remote-master创建新分支remotes/master/master。要让本地remote-master分支跟踪远程分支,请使用git checkout选项调用--track

要查看当地分支机构跟踪哪个远程分支,请调用git branch -v

您应该阅读git简介(例如https://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell)以开始使用git。