Why does git revert complain about a missing -m option?

后端 未结 3 1943
不思量自难忘°
不思量自难忘° 2020-11-29 15:16

So I\'m working on a project with other people, and there\'s multiple github forks being worked on. Someone just made a fix for a problem and I merged with his fork, but the

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-29 16:01

    By default git revert refuses to revert a merge commit as what that actually means is ambiguous. I presume that your HEAD is in fact a merge commit.

    If you want to revert the merge commit, you have to specify which parent of the merge you want to consider to be the main trunk, i.e. what you want to revert to.

    Often this will be parent number one, for example if you were on master and did git merge unwanted and then decided to revert the merge of unwanted. The first parent would be your pre-merge master branch and the second parent would be the tip of unwanted.

    In this case you could do:

    git revert -m 1 HEAD
    

提交回复
热议问题