Undoing a Merge
Revert -m 1.
You merged a branch into main, and pushed it. Then you discover the branch broke the site. Since it's shared, reset is off the table. You need to revert the merge.

- A bad merge, already pushed
- Reset is off the table
- Revert the merge
git revert -m 1
The log shows our merge commit on top. Reverting a merge needs one extra option, dash m one. A merge commit has two parents, and dash m one tells Git to keep the first parent, which is main, and undo what the branch brought in. Git makes a new commit, and the huge text is gone.
git log --oneline -n 3 312954a (HEAD -> main) Merge branch redesign b4bf8c2 (redesign) Huge text redesign f63a17a Link to about page git revert -m 1 --no-edit HEAD [main 0e45ab5] Revert "Merge branch redesign" Date: Mon Jan 5 09:38:49 2026 +0000 1 file changed, 1 deletion(-) git log --oneline -n 2 0e45ab5 (HEAD -> main) Revert "Merge branch redesign" 312954a Merge branch redesign tail -1 style.css body { font-family: sans-serif; }
Good to know
Dash m one is almost always what you want, because the first parent is the branch you merged into. And remember, the revert is just a normal commit. So if the branch is fixed later, and you want it back, you revert the revert.
Summary
To undo a pushed merge, use git revert dash m one, and the merge commit. Next, rescuing work made on a detached head.
Key takeaways- git revert -m 1 <merge>
- Keeps main's side
- Safe after pushing