2

If I do a commit in Mercurial and then realise I haven't added enough information to the commit message, is there a way to just add another message or note without commiting anything else? What is the best way to get that extra info in there?

I realise I can sometimes rollback and commit again but that is not always possible. I don't want to rewrite history either, I just want to add information.

SoftDeveloper
  • 160
  • 1
  • 8
  • possible duplicate of [How to edit incorrect commit message in Mercurial?](http://stackoverflow.com/questions/623052/how-to-edit-incorrect-commit-message-in-mercurial) – jk. Mar 02 '11 at 11:06
  • 3
    There was a discussion about this recently on the Mercurial mailinglist: http://mercurial.markmail.org/thread/skalggb4typm27um See that message for an extension that does what you want. – Martin Geisler Mar 02 '11 at 14:11
  • Thanks Martin, that pretty much answers my question. – SoftDeveloper Mar 02 '11 at 16:31

2 Answers2

3

Unless you're willing to get into editing history using MQ or histedit (and in Mercurial that's not usual practice) or it was the latest commit (rollback) then you need to commit something else to be able to add another changeset with a different commit message.

Mercurial is built around the concept of an "immutable history" and it intentionally restricts tools that let you alter the past.

Ry4an Brase
  • 78,112
  • 7
  • 148
  • 169
  • 2
    I understand the "immutable history" thing and I don't want to change the past, I just want to add info to it. Kind of like Tags but with more text. Martin Geisler's comment pretty much answers my question. – SoftDeveloper Mar 02 '11 at 16:30
  • Yeah, I like (some of) the suggestions in that thread. It'll be interesting to see if it goes anywhere. – Ry4an Brase Mar 02 '11 at 16:43
  • It could still have immutable history for the actual payload (ie: code) and let you improve the comment description. Which is not altering the past since the code can be made immutable, just let you make the comment more useful. – Efren Nov 12 '13 at 01:32
  • The comment is included in the hash of the changeset, so changing just the comment would alter the commit hash and force reparentage of all subsequent commits in all clones. – Ry4an Brase Nov 12 '13 at 02:46
0

If this was your last commit then you could rollback and commit again (with the new message).

Teo Klestrup Röijezon
  • 5,097
  • 3
  • 29
  • 37
  • Yes but not always possible, eg on the first commit, would I have to delete the repo and start again? Quite often I want to add info about the repo/project later. – SoftDeveloper Mar 02 '11 at 12:02
  • @SoftDeveloper for adding information about the repo/project itself, maybe adding a `README` would make sense? – binki Oct 21 '15 at 16:06