Mercurial:Remove last commit

mercurial

Solution

If you are still in the draft phase (not pushed elsewhere yet), use the built-in extension `hg strip <rev>` command. Otherwise, you should do a `hg backout`, which will reverse the changeset.

In case you still need the commit you made, I suggest you `export` it to `import` it again in the correct branch, before stripping.

Problem

I was working in default, but thought to be working in another branch. I commited, but didn't push. Now I want to change branches and commit the changes to another branch, but also dont want the commit to go to default. How do I undo that commit?

Original source