After my last commit I wrote a bunch of code. Before committing again, I ran hg add.
It added some files I was not interested in, so I ran
$ hg revert --all
thinking that all the added files would go away. They did go away, but I also reverted all the code written since the last commit, which means a ton of work was lost! What are my options?
When you
hg reverta file (or--allfiles), Mercurial saves a backup of the file under another name. This is to make it harder for you to lose work. If the file was calledfoo, you will have afoo.origwith the original version.You can use
to see all the
.origfiles in your working copy. Move the ones you need back, re-add them and commit.On a related note: people sometimes add the
--no-backupflag to their[defaults]section in order to get rid of the.origfiles Mercurial scatter around. I think this a really bad idea… just ignore the.origfiles instead by addingto your
.hgignorefile. That’s much safer and one day you’ll be happy that you have these.origfile lying around 🙂