如何在 Mercurial 中编辑错误的提交消息? [英] How to edit incorrect commit message in Mercurial?

查看:19
本文介绍了如何在 Mercurial 中编辑错误的提交消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用 TortoiseHg (Mercurial) 并且不小心提交了错误的提交消息.如何在存储库中编辑此提交消息?

I am currently using TortoiseHg (Mercurial) and accidentally committed an incorrect commit message. How do I go about editing this commit message in the repository?

推荐答案

更新: Mercurial 添加了 --amend 应该是 现在首选.

Update: Mercurial has added --amend which should be the preferred option now.

您可以使用 hg rollback 回滚最后一次提交(但仅限最后一次提交),然后重新应用它.

You can rollback the last commit (but only the last one) with hg rollback and then reapply it.

重要:这永久删除最新提交(或拉取).所以如果你做了一个 hg update 提交不再在你的工作目录中,那么它就永远消失了.所以先复制一份.

Important: this permanently removes the latest commit (or pull). So if you've done a hg update that commit is no longer in your working directory then it's gone forever. So make a copy first.

除此之外,您不能更改存储库的历史记录(包括提交消息),因为其中的所有内容都是经过校验和的.您唯一能做的就是在给定的变更集之后修剪历史记录,然后相应地重新创建它.

Other than that, you cannot change the repository's history (including commit messages), because everything in there is check-summed. The only thing you could do is prune the history after a given changeset, and then recreate it accordingly.

如果您已经发布了您的更改(除非您可以获得所有副本),并且您也不能重写历史记录",其中包括 GPG 签名的提交(由其他人),那么这些都将不起作用.

None of this will work if you have already published your changes (unless you can get hold of all copies), and you also cannot "rewrite history" that include GPG-signed commits (by other people).

这篇关于如何在 Mercurial 中编辑错误的提交消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆