Elentok's Blog

About me

Tip: Removing a changset from a Mercurial repository

The rollback command only removes the latest changeset, if you want to remove/undo multiple changesets (and all of their descendants) from a repository you can use the "strip" method that comes with the "Mq" extension:

Step 1 - Enable the Mq extension

The Mq extension is distributed with Mercurial so to enable it just edit ~/.hgrc (in windows: C:\Users\UserName.hgrc) and add the following lines:

[extensions]
  mq=

If you use TortoiseHg, then you can just open the settings page, and in the Extensions section enable "mq".

Step 2 - Remove a changeset

Find the revision number of the changeset you wish to remove (via TortoiseHg or hg log) and execute the following command:

> hg strip <revision-number>

If you mess up you can restore the changeset by running:

> hg unbundle .hg/strip-backup/filename
Next:Mercurial: Automatically run unittests before commit