Reverting a git merge while allowing for the same merge later)

后端 未结 3 1483
时光取名叫无心
时光取名叫无心 2020-12-07 00:14

What\'s the best way to revert a committed git merge while keeping the option of merging the same branch at a later point?

This is for a situation when I merge a bra

3条回答
  •  不思量自难忘°
    2020-12-07 00:33

    Sorry to say that you have wasted your branch.

    But there is a workaround. The trick is to "rewrite" the merge commit temporarily so that it forgets that the branch is a parent. Assume X is the merge commit:

    git replace --graft X X^   # pretend that there is just one parent
    git merge branch           # merge the branch again
    git replace --delete X     # remove the replacement
    

提交回复
热议问题