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.
Your
git cleancommand remove untracked files from the working tree, including ignored files. The equivalent Mercurial command is provided by the standard purge extension:Remove the
--printto actually delete the files, remove--allto 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
then you need to enable the mq extension and run
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.)