mercurial

How to revert a Mercurial hg pull?


If you do an hg pull and then an hg update (or an hg merge), is there a way to back this out? Ie: revert your repository to the state prior to doing the hg pull?

I believe you can do hg update -r n where you would specify the changeset prior to the pull as n. Though I'm guessing this will still leave the changesets in your repository but this isn't really what we want. ??


Solution

  • hg strip will remove revisions from a repository. Like all powerful commands, its dangerous, so be careful.

    https://www.mercurial-scm.org/wiki/StripExtension

    Also see:

    https://www.mercurial-scm.org/wiki/EditingHistory

    If you catch your mistake immediately (or reasonably soon), you can just use hg strip REV to roll back the latest (one or more) changes. ...