How to revert a merge commit that's already pushed to remote branch?

后端 未结 17 2049
无人及你
无人及你 2020-11-22 07:04

git revert alone won\'t work. -m must be specified, and I\'m pretty confused about it.

Anyone experienced this before?<

17条回答
  •  南旧
    南旧 (楼主)
    2020-11-22 07:58

    This is a very old thread, but I am missing another in my opinion convenient solution:

    I never revert a merge. I just create another branch from the revision where everything was ok and then cherry pick everything that needs to picked from the old branch which was added in between.

    So, if the GIT history is like this:

    • d
    • c
    • b <<< the merge
    • a
    • ...

    I create a new branch from a, cherry pick c and d and then the new branch is clear from b. I can ever decide to do the merge of "b" in my new branch again. The old branch becomes deprecated and will be deleted if "b" is not necessary anymore or still in another (feature/hotfix) branch.

    The only problem is now one of the very hardest things in computer science: How do you name the new branch? ;)

    Ok, if you failed esp. in devel, you create newdevel as mentioned above, delete old devel and rename newdevel to devel. Mission accomplished. You can now merge the changes again when you want. It is like never merged before....

提交回复
热议问题