Reverse a merge relative to a chosen parent.
Section: Revert Basics
Revert a merge commit
bash
bash
git revert -m 1 <merge_commit_sha>Explanation
Reverting a merge requires specifying the mainline parent. Be careful because later merges can behave differently after this.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Revert Basics
Revert a single commit
Create a new commit that reverses an earlier commit.
Revert several commits without auto-committing
Apply inverse changes into the index and working tree first.
Mental model for reset vs restore vs revert
Quick decision guide for the three similarly named commands.
Reset out of a conflicted merge state
Try to leave local changes intact while backing out of a merge-like operation.
Undo last commit but keep everything staged
Move HEAD back one commit while preserving index and working tree.