How To Revert a Merge Commit
July 06, 2021
If you merged a PR you didn't want to, and you need to undo it, here's how. Note that there are some caveats
git revert -m 1 <commit-sha>
-m option, we're specifying the mainline, which I'm willing to bet for you is the thing you merged into. (
Because you can easily revert them in a single, clean action, I'm a fan of merge commits.
But if you didn't use them, you have to do just a normal revert of all the necessary commits. Which I think is more error prone, unless you squashed all of them into one commit (which is also a perfectly fine option).
Here's the long version of this post.