我目前正在使用TortoiseHg (Mercurial),不小心提交了一个错误的提交消息。如何在存储库中编辑这条提交消息?


当前回答

上面讨论的一个小宝石-感谢@Codest和@Kevin Pullin。 在TortoiseHg中,在提交按钮旁边有一个下拉选项。选择“修正当前修订”会带回注释和文件列表。所以有用。

其他回答

我以前是这么做的:

想象一下,您有500个提交,错误的提交消息在r.498中。

hg qimport -r 498:tip
hg qpop -a
joe .hg/patches/498.diff
(change the comment, after the mercurial header)
hg qpush -a
hg qdelete -r qbase:qtip

回滚-重新应用是一个非常简单的解决方案,但它只对最后一次提交有帮助。Mercurial Queues功能强大得多(注意,为了使用“hg q*”命令,您需要启用Mercurial Queues Extension)。

上面讨论的一个小宝石-感谢@Codest和@Kevin Pullin。 在TortoiseHg中,在提交按钮旁边有一个下拉选项。选择“修正当前修订”会带回注释和文件列表。所以有用。

我知道这是一个老帖子,你把问题标记为答案。我正在寻找同样的事情最近,我发现histedit扩展非常有用。这个过程解释如下:

http://knowledgestockpile.blogspot.com/2010/12/changing-commit-message-of-revision-in.html

使用MQ扩展和调试命令还有另一种方法。这是在不丢失数据的情况下修改历史记录的一种通用方法。让我假设和安东尼奥的情况一样。

// set current tip to rev 497
hg debugsetparents 497
hg debugrebuildstate
// hg add/remove if needed
hg commit
hg strip [-n] 498