Is it possible to edit a summary after a commit using TortoiseHg?

前端 未结 7 1578
清酒与你
清酒与你 2021-01-04 01:30

Occasionally I commit some code to the repository, add a comment/summary, then read the summary back and realise I\'ve made a mistake or should have included a bit more info

7条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-04 02:11

    Phil - I'll post the same answer I just posted on this question (asked after yours):

    One appropriate way to do this is to use histedit. Histedit allows you to remove, modify, combine or otherwise edit your previous commits.

    Histedit does not ship with Mercurial and it cannot be used with TortoiseHg, but the command line usage is very simple:

    > hg histedit

    where is the revision you want to change the comment on. Histedit will generate a list of changesets and show you their SHA1. Besides each changeset there is a word indicating what histedit will do with each changeset once you close the text window. Next to the changeset you want to modify - replace 'pick' with 'edit'. Close the text window and then issue this command:

    > hg histedit --continue

    and another text window will appear containing the log message. Change the message to whatever you want. You can do this for multiple changesets in one go, provided the files have not been shared yet. This is a pretty trivial use of histedit, more complicated uses involved combining commits or removing a portion of some commit.

提交回复
热议问题