Finding the Real Merge to Back Out
git log --oneline --merges -3
git show --stat <merge-hash>
A real, complete feature — two commits, one clean merge, now to be backed out entirely.
Why -m 1 Is Required
A merge commit has two real parents: the branch being merged INTO (master, parent 1) and the branch being merged IN (the feature, parent 2). git revert cannot guess which side represents "normal" and which represents "the change to undo" — -m 1 tells it explicitly: treat parent 1 (master) as the mainline, and undo everything the OTHER side introduced.
git switch -c revert/protein-shakes
git revert -m 1 <merge-hash>
A real, single new commit that removes everything the entire feature added — the whole file, gone, in one real, clean commit.
Landing It Normally
git switch master
git merge --no-ff revert/protein-shakes -m "Merge pull request: revert protein shakes"
git push
Sometimes the problem is not one bad line — it is an entire real feature the team decides not to ship after all. Grace Hopper's protein-shakes feature merged cleanly, two real commits, no conflicts. Now it needs to come out completely.
git revert works on merge commits too — but a merge has two real parents, and git genuinely cannot guess which side is "the one to keep." The -m 1 flag tells it explicitly: parent 1 is master, the side to revert back to. This one real flag is behind one of the most commonly searched git questions there is.
git revert -m 1 <merge-commit>
Reverts an entire real merge commit at once, using parent 1 (specified by -m) as the real mainline to revert back to. Confirmed directly in this lab: the whole protein-shakes feature, both real commits, removed in one clean revert.
Merge commit parents
A real merge commit always has two parents: parent 1 is the branch that was checked out (master), parent 2 is the branch that was merged in. -m 1 makes this real ordering explicit to revert, since it cannot be inferred automatically.
Takeaways
- git revert works on merge commits, not just regular ones — real, genuinely useful for backing out a whole feature
- -m 1 tells git which parent of the merge is the real mainline to revert back to
- One real revert commit undoes everything a whole feature introduced, cleanly, in a single operation
- Backing out a whole feature still goes through the same real, reviewed PR process as shipping one