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?
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.
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.
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With