带有 Mercurial 的 Sourcetree。撤消尚未推送的提交

Sourcetree with Mercurial. Undo commit that has not been pushed

我有一个 Mercurial 存储库并且已经提交但没有推送它。 我想撤消提交 我查看了 the help here,但没有为我显示菜单选项 "Reset Master to this commit "。 我认为该命令将是 hg rollback。 Sourcetree 中是否有菜单选项可以执行此操作?

hg rollback 已弃用。目前推荐使用hg commit --amend.

来自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.

根据 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 建议在这种情况下使用条带功能,这似乎是一个很好的解决方案。

来自该线程(支持修改之前):

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.