Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to edit incorrect commit message in Mercurial? [duplicate]

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?

like image 756
maxyfc Avatar asked Mar 08 '09 04:03

maxyfc


People also ask

How do I change the wrong commit message?

On the command line, navigate to the repository that contains the commit you want to amend. Type git commit --amend and press Enter. In your text editor, edit the commit message, and save the commit.

Can I edit my commit message?

To change the most recent commit message, use the git commit --amend command. To change older or multiple commit messages, use git rebase -i HEAD~N . Don't amend pushed commits as it may potentially cause a lot of problems to your colleagues.

What is HG amend?

hg amend [OPTION]... [ FILE]... aliases: refresh. combine a changeset with updates and replace it with a new one. Commits a new changeset incorporating both the changes to the given files and all the changes from the current parent changeset into the repository.


1 Answers

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


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

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.

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).

like image 133
Thilo Avatar answered Oct 18 '22 10:10

Thilo