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?
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.
A simple way to 'uncommit' your last commit is to use hg strip -r -1 -k. In case the link breaks, the documentation mentioned by @phb states: hg rollback Roll back the last transaction (DANGEROUS) (DEPRECATED) Please use 'hg commit --amend' instead of rollback to correct mistakes in the last commit.
You need to login to the server and use the hg strip command. If you cannot login to the server, you are out of luck; you can hg backout then push again, but this will leave the bad commits on the server along with the commit that undoes them. Show activity on this post. hg revert -r .
In the TortoiseHg client's Commit dialog, right-click the needed file and then click Revert.
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.
If "another branch" already exist, you must move changeset to it, using hg rebase
(rebase extension have to be enabled)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With