Reputation: 18198
I have a Mercurial repository and have made a commit but not pushed it. I want to undo the commit I looked at the help here but the menu option "Reset Master to this commit " does not appear for me. I think the command would be hg rollback. Is there a menu option in Sourcetree to do this?
Upvotes: 2
Views: 3148
Reputation: 764
hg rollback
is deprecated. The current recommendation is to use hg commit --amend
.
From http://www.selenic.com/mercurial/hg.1.html#commit:
The --amend flag can be used to amend the parent of the working directory with a new commit that contains the changes in the parent in addition to those currently reported by hg status, if there are any. The old commit is stored in a backup bundle in .hg/strip-backup (see hg help bundle and hg help unbundle on how to restore it).
Message, user and date are taken from the amended commit unless specified. When a message isn't specified on the command line, the editor will open with the message of the amended commit.
According to http://www.sourcetreeapp.com/update/ReleaseNotes.html, Sourcetree is capable of amending a commit since version 1.9.0, but an older thread in answers.atlassian.com suggests using the strip feature in this case and it seems like it is a good solution.
From that thread (before amend was supported):
In Mercurial, you can 'strip' commits, which SourceTree exposes in the log view context menu. If you right-click a commit and choose 'Strip from here', it will destroy that commit at all of its children. However, if you check the box 'Do not modify working copy', you can keep all the changes, and they will become uncommited changes which you can then commit again. So this is similar to the idea of 'amend last commit' if you use it on the latest commit and check the 'Do not modify working copy' box (very important!), then commit again, although Mercurial does this a bit differently.
Upvotes: 2