How do I do a pristine checkout with mercurial?

git, mercurial

Solution

Your `git clean` command remove untracked files from the working tree, including ignored files. The equivalent Mercurial command is provided by the standard purge extension:

hg clean --all --print

Remove the `--print` to actually delete the files, remove `--all` to only delete untracked files and leave ignored files behind.

If you also want to discard local changesets that haven't been pushed, i.e., the equivalent of

git reset --hard origin/master

then you need to enable the mq extension and run

hg strip "outgoing()"

Your local clone will now look just like when you first cloned it.

(Yes, we also have sharp tools in our toolbox, but they're hidden away until you decide to use them.)

Problem

How do I get the working directory state back to what it would have been from a new clone of the repository (Obviously I could clone my repository, but that seems a bit savage.) With git I'd do: ``` git clean -xdn (dry-run, to see what I'm about to destroy) git clean -xdf (force, to actually do it) ``` And I'm assuming that there's probably a subtly different mercurial equivalent, but I can't find it.

Original source