HG: Undo a commit from history

Donn Felker picture Donn Felker · May 6, 2011 · Viewed 26.5k times · Source

I have a HG repository with revs 1, 2, 3, 4, 5 and 6.

When I committed rev 4, I unknowingly botched some changes in rev3 that I should not have. I did not notice this until rev 6 was already committed.

I need to undo changes in rev 4, but then re-apply all other changes after that. Basically undoing commit #4. How can I do that?

Answer

Jim Bolla picture Jim Bolla · May 6, 2011

You want hg backout

Revert/undo the effect of an earlier changeset...

Backout works by applying a changeset that's the opposite of the changeset to be backed out. That new changeset is committed to the repository, and eventually merged...