How to move master to HEAD?

前端 未结 2 1452
没有蜡笔的小新
没有蜡笔的小新 2020-12-24 01:01
* [971f835] (HEAD, original_idea) Now working here. Some comment 9
* [692b673] Some comment 8
* [3ebff62] Reverted to original idea. Some comment 7
| * [72ea01d] (ma         


        
2条回答
  •  悲&欢浪女
    2020-12-24 01:44

    If git branch shows that your current branch is original_idea, that wouldn't be a detached HEAD situation.

    But in any case, if you want your master to reflect your "current commit" (which is what HEAD means in Git):

    git branch -f master HEAD
    git checkout master
    

    You would find other alternatives in "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.

    Then all you need to do is:

    • make sure HEAD is referenced by a branch (like original_idea on your schema)
    • rebase that branch on top of master:

    That would mean:

    git checkout original_idea
    git rebase master
    git checkout master
    git merge original_idea
    

提交回复
热议问题