How can I undo my last accidentally commited (not pushed) change in Mercurial?
If possible, a way to do so with TortoiseHg would be prefered.
Update
In my concrete case I commited a changeset (not pushed). Then I pulled and updated from the server. With these new updates I decided, that my last commit is obsolete and I don't want to sync it. So it seems, that hg rollback
is not exactly what I'm searching for, because it would rollback the pull instead of my commit.
hg rollback
, and then pulling again? – Jessalynstrip --keep
: #29414351 directly solves the task, as does MQ qimport. Alternatively, it may be better simply torebase
in the scenario if the local changes are also to be kept and there is no conflict. (Use a merge to keep some combined changes from both branches when that is the desired graph end-goal, especially on a non-fastforward case.) It may also be valid just to close the branch, which still 'preserves history' (but differently than a merge) depending on the final state desired. – Publeahg strip --keep
is the command do use, but you need to provide a revision, e.g.:hg strip --keep -r .
. This answer explains well https://mcmap.net/q/103180/-mercurial-hg-equivalent-of-git-reset-mixed-or-soft – Endomorphhg commit --amend
instead, but doesn't explain how to use it to "undo the last commit" as per your question. – Endomorph