How do you revert a merge commit, and why is it trickier than reverting a normal commit?

Last updated 6 July 2026

  • Use git revert -m 1 <sha> to keep the first parent (the mainline) and undo the merged-in changes. Without -m, Git errors because a two-parent merge is ambiguous.

  • The revert undoes content but history still records the branch as merged. Re-merging later won't bring those commits back.

  • To reintroduce the branch's work, revert the revert (or rebase the branch).

  • https://seymour.co.za/2022/05/08/revert-git-merge/
  • https://www.runxbuild.com/blog/git-revert-merging/
  • https://dev.to/gabeguz/git-revert-merge-commits-confusion
  • https://www.warp.dev/terminus/git-undo-merge
  • https://www.gosquared.com/blog/reverting-git-merges
  • https://edezekiel.medium.com/reverting-a-faulty-merge-and-fixing-the-feature-branch-4d2fb437a9b5
  • https://git-scm.com/docs/git-revert.html
  • https://www.geeksforgeeks.org/git/how-to-revert-a-pushed-merge-commit-in-git/
All Git interview questions