Using Mercurial's hg revert -aC
, or with long option names, hg revert --all --no-backup
I can reset my working copy to head.
I.E., which ever branch I'm on, it'll update the working copy to be the latest commit on that branch that the local repo contains.
In particular:
- If I have commits in my local repository, it definitely won't discard those commits.
- It will remove untracked files that are not ignored files.
- It will leave ignored files alone.
I find this to be one of the most essential basic commands for working with a repo. I'll often make some exploratory changes to a few files and then want to abandon this to do begin real work from a pristine set.
How do I do that this git
?
This is logged as a duplicate of How do I use 'git reset --hard HEAD' to revert to a previous commit?. That question (and questions it links to) has answers that are a useful resource to answer this question. However, this question is specifically asking how a mercurial user should achieve part of their work flow using git instead.