Git: how to reverse-merge a commit?

前端 未结 5 641
日久生厌
日久生厌 2020-12-07 11:46

With SVN it is easy to reverse-merge a commit, but how to do that with Git?

5条回答
  •  隐瞒了意图╮
    2020-12-07 12:16

    To revert a merge commit, you need to use: git revert -m . So for example, to revert the recent most merge commit using the parent with number 1 you would use:

    git revert -m 1 HEAD
    

    To revert a merge commit before the last commit, you would do:

    git revert -m 1 HEAD^
    

    Use git show to see the parents, the numbering is the order they appear e.g. Merge: e4c54b3 4725ad2

    git merge documentation: http://schacon.github.com/git/git-merge.html

    git merge discussion (confusing but very detailed): http://schacon.github.com/git/howto/revert-a-faulty-merge.txt

提交回复
热议问题