Git: move a commit “on top”

前端 未结 2 1004
孤独总比滥情好
孤独总比滥情好 2020-12-14 00:45

Let\'s say in master I have a feature disabled. I work on that feature on branch feature, so I have a special commit $ there that just

2条回答
  •  执笔经年
    2020-12-14 01:43

    If you want to keep you commits in the same order on feature you should make a new branch and perform the following. Otherwise just do this on feature

    git rebase -i 
    

    Move commit $ to the bottom of the list

    git checkout master
    git rebase feature 
    

    It wasn't clear to me on the question but if you didn't want $ at all, rather than moving it delete it after git rebase -i Though you will want to do this on a new branch so that you don't lose it. As you are changing history.

    This also assumes that the branch feature hasn't been pushed to a remote as rewriting history is bad.

提交回复
热议问题