Skip to content
The Git Crypt

/static/cripta/en/ossada/revert-m/

Menu

GIT-024 · Surgery

git revert -m

Undoes a whole merge by choosing which parent still counts.

Reverting an ordinary commit is trivial; a merge commit has two parents, and git needs to know which side of the union stays standing. -m 1 declares the first parent — usually the branch that received the merge — as the mainline, and the revert undoes everything the other side brought in.

The surgical warning, straight from the documentation: the revert undoes the data, not the ancestry. The reverted branch remains technically merged — to bring it back later, fixed, you must first revert the revert itself.

$ git revert -m 1 3e7a9c2
[main 8b1c4d5] Revert "Merge branch 'comentarios'"
The merge undone; the first parent still stands.