* [971f835] (HEAD, original_idea) Now working here. Some comment 9
* [692b673] Some comment 8
* [3ebff62] Reverted to original idea. Some comment 7
| * [72ea01d] (master) Decided it wasn't worth the effort. Some comment 6
| * [985c1ad] Some comment 5
| * [4d7d491] Some comment 4
| * [0c697bb] Branched to try an idea. Some comment 3
|/
* [7280b1f] Some comment 2
* [5c2c6d0] Some comment 1
* [bc7aac6] Initial commit
所以,master
落后了。不知道那是怎么发生的。一旦我决定我完成了没有成功的分支,我检查了 [7280b1f]
并从那里继续。
我该如何解决这个问题?这是臭名昭著的“分离头”问题吗?
master
是否必须与 HEAD
保持一致才能使存储库达到最佳运行状态?
我的工作流程 super 简单。这只是管理一个文本文件。在绝大多数情况下,它是:
git add .
git commit -am "Some comment"
就是这样。
我决定尝试一个想法并创建一个分支。当它没有成功时,我检查了那个分支的根并返回到 git add/commit
例程。
最佳答案
如果 git branch
显示您当前的分支是 original_idea,那将不是 detached HEAD situation .
但无论如何,如果您希望您的主人反射(reflect)您的“当前提交”(即 what HEAD means in Git ):
git branch -f master HEAD
git checkout master
您会在“How to I “move” my commits from “no branch” to an actual branch?”中找到其他替代方案。
The problem with this is that it makes the entire branch currently ending at master disappear.
那么你需要做的就是:
- 确保 HEAD 被一个分支引用(比如你的模式中的
original_idea
) - 在 master 之上重新设置分支:
这意味着:
git checkout original_idea
git rebase master
git checkout master
git merge original_idea
关于git - 如何将 master 移动到 HEAD?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26570242/