Git reset. Mercurial. Two worlds. One problem: undoing changes without burning down your project history. If you’ve ever switched between Git and Mercurial, you know that each has its own way of rewriting history, cleaning up commits, and moving your branch pointer around. But the mental model can be slippery. That’s why knowing how Git reset maps to Mercurial’s commands will save you hours of damage control.
What Git Reset Actually Does
In Git, reset moves the current branch to a specific commit, optionally updating the working directory and the staging area.
git reset --softchanges the commit position but keeps files as staged.git reset --mixedkeeps your working files but un-stages changes.git reset --hardwipes both staging and working copies to match the chosen commit.
It’s precise and unforgiving, which is the point. But that also makes it dangerous if you don’t have a backup.
Mercurial’s Way of Rewriting
Mercurial doesn’t have a direct one-word equivalent to git reset. Instead, there are several approaches:
- hg update -C [rev]: Similar to
git reset --hard. Discards uncommitted changes and moves to the specified revision. - hg backout [rev]: Generates a new commit to undo an earlier one, keeping a clean history.
- hg strip [rev] (requires the strip extension enabled): Removes changesets and everything after them, like a permanent reset. This is closest to Git’s destructive reset.
Where Git’s reset alters the branch reference in place, Mercurial’s defaults lean toward creating new history or cleanly rolling back without rewriting for everyone.