How do you "rollback" last commit on Mercurial?

serhio picture serhio · Dec 9, 2013 · Viewed 96.9k times · Source

I have a Mercurial repository that I use in local only... It's for my personal usage (so I don't "push" anywhere).

I made a commit with 3 files, but after that I understood that I should do commit 4 files...

Is there a way to "rollback" my last (latest, only one) commit, and "recommit" it with the correct files?

(I don't know why, but my "Amend current revision" option is not active, so I can't use it...)

Answer

Martin Eden picture Martin Eden · Dec 9, 2013

You just need this command:

hg rollback

See: http://hgbook.red-bean.com/read/finding-and-fixing-mistakes.html.

(Technically, this is deprecated as of version 2.7, August 2013, but I've yet to see an alternative that does exactly the same thing.)