繁体   English   中英

无法切换到“远程分支”-头已分离

[英]Unable to switch to 'Remote Branch' - Head Detached

无法切换到“远程分支”-头已分离

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

  [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...))]$

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

要查看本地分支跟踪的远程分支,请调用git branch -v

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM