1

我的本地 Git 分支发生了什么?这是我运行的命令序列:

$ git fetch --all
$ git branch
* feature/myfeature1
  master
  branch-dev
$ git branch -a
* feature/myfeature1
  master
  branch-dev
  remotes/origin/bugfix/bug-on-user
  remotes/origin/feature/myfeature2
$ git checkout origin/bugfix/bug-on-user
M       com.soc.data/.settings/org.eclipse.jdt.core.prefs
M       com.soc.data/META-INF/MANIFEST.MF
Note: checking out 'origin/bugfix/bug-on-user'.

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 d467d95... ...

$git branch
* (detached from origin/bugfix/bug-on-user)
   feature/myfeature1
   master
   branch-dev

为什么我的分支是分离的?我做错了什么?

4

1 回答 1

2

你需要

git checkout bugfix/bug-on-user

不是

git checkout origin/bugfix/bug-on-user

否则它不会是本地分支......好吧,实际上它将是一个本地分支,但不是你的意思,它将是一个remote-tracking-branch,这是一个你永远不应该直接工作的分支,但是从远程存储库中提取/获取数据时使用。

于 2015-03-19T16:27:35.160 回答