Can my changes go away after "hg revert"?

After my last commit, I wrote a bunch of code. Before trying again, I ran hg add . He added some files that didn't interest me, so I ran

 $ hg revert --all 

thinking that all added files will disappear. They left, but I also returned all the code written since the last commit, which means that a ton of work has been lost! What are my options?

+7
source share
1 answer

When you hg revert file (or --all files), Mercurial saves a backup copy of the file under a different name. This should complicate your work. If the file was called foo , you will have foo.orig with the original version.

you can use

 $ hg status --all --include "**.orig" 

to view all .orig files in your working copy. Move the ones you need, re-add them and lock.

In a note: people sometimes add the --no-backup flag to their [defaults] section to get rid of .orig Mercurial files. I think this is a really bad idea ... just ignore .orig files by adding

 syntax: glob *.orig 

into your .hgignore file. This is much safer, and one day you will be happy that you have a .orig file lying around .orig

+12
source

All Articles