views:

106

answers:

3

How do you abandon all repository changes since the last commit in Mercurial?

I don't think that this is the revert command, because that will actually update the working directory to the last commit. I just want to undo changes in the repository (added files, removed files, etc).

But, I'm new with Mercurial, so I could be missing something.

+1  A: 

This previous question may help: http://stackoverflow.com/questions/2540454/mercurial-revert-back-to-old-version-and-continue-from-there

Particularly Martin's "cheat sheet" answer.

Paolo
+2  A: 

You do want revert. The two commands revert and update are complimentary. They both update the files in your working directory, but update also updates the parent revision (see hg parents) whereas revert doesn't. If your parent revision was tip, which it often is, then either would do in this case, but prefer revert.

Example:

ry4an@hail [~/hg/test] % hg stat
? newfile
? output.patch
? this
ry4an@hail [~/hg/test] % hg add newfile
ry4an@hail [~/hg/test] % hg stat
A newfile
? output.patch
? this
ry4an@hail [~/hg/test] % hg revert --all
forgetting newfile
ry4an@hail [~/hg/test] % hg stat
? newfile
? output.patch
? this
Ry4an
A: 

Any changes to your local copy that have not been committed to the repository can be undone with the command:

hg update -C

That is, update clean.

bishboshbash