mercurial - new - hg revert uncommitted changes

Using hg revert in Mercurial (6)

As other's have pointed out, you can safely delete these files.

You can remove them by executing this command from the root of your repo:

rm `hg st -un | grep orig`

If you want to revert, and don't care at all about backing up the original files, the command you want is:

hg update -C

I'm using Mercurial. I made a clone of a repository. For debugging, I changed a few lines of code in a java file. I did not commit those changes though. I just want to revert them back to their original state, as found in the repository. I tried hg revert, which did revert it, but now when I do hg status, I see additional files added in my folder now like:


Can I just delete those files, and why does Mercurial make them when I use revert?

I find the purge extension handy. Usage:

hg purge

"This extension purges all files and directories not being tracked by Mercurial" - including the .orig files but excluding ignored files (unless you use --all).

These are rather common, resulting from various operations. A glance at one of the moderate sized repositories I work on finds 237 of them. I don't like deleting things that may end up being useful, and I have no reason to name legitimate files with the same suffix, so I add the following to .hgignore instead:


These backup files can be created for merge and revert operations (cf. man page). You can add an ignore rule if you want, or simply delete them if you don't need them anymore.

Yes, you can delete them. It's a safety feature in case you reverted something you didn't mean to revert.

You can also use the flag --no-backup and the .orig files will not be created

hg revert --no-backup

As of Mercurial 2.0, you can instead use the flag -C to supress the .orig files from being created

hg revert -C