Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I customize git's merge commit message?

Tags:

git

git-merge

Every time I do a merge I need for a merge commit to be generated and I would like it to have more than just the summary of all the commits.

My question is how can I format git-fmt-merge-msg or what determines this automated message (I can do this manually after a commit by amending it and using git-log --pretty=format:'...')

For example I would like to format it as such:

 Merge branch 'test'       * test:         [BZ: #123] fifth commit subject         [BZ: #123] fourth commit subject         [BZ: #123] third commit subject         [BZ: #123] second commit subject         [BZ: #123] first commit subject     __________________________________________  Merge details:        [BZ: #123] fifth commit subject                  at 2010-06-30 11:29:00 +0100          - fifth commit body         [BZ: #123] fourth commit subject                  at 2010-06-30 11:22:17 +0100          - fourth commit body         [BZ: #123] third commit subject                  at 2010-06-30 11:21:43 +0100          - third commit body         [BZ: #123] second commit subject                  at 2010-06-30 11:21:30 +0100          - second commit body         [BZ: #123] first commit subject                  at 2010-06-30 11:29:57 +0100          - first commit body 
like image 363
shil88 Avatar asked Jun 30 '10 11:06

shil88


People also ask

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.

How do I change my initial commit message?

To amend the message of your last Git commit, you can simply execute the “git commit” command with the “–amend” option. You can also add the “-m” option and specify the new commit message directly. As an example, let's say that you want to amend the message of your last Git commit.


2 Answers

Looks like as of version Git 1.7.8 you can do git merge --edit ... to specify the commit message.

And as of 1.7.10, dropping into edit mode will be the default behavior

From this release on, the "git merge" command in an interactive session will start an editor when it automatically resolves the merge for the user to explain the resulting commit, just like the "git commit" command does when it wasn't given a commit message.

(though I'm not seeing it on in msysgit on windows).

like image 37
Roman Avatar answered Oct 20 '22 16:10

Roman


I'm aware this isn't answering the original question, but for the benefit of git noobs like myself who reach this page because it's currently the first Google result for "git change merge commit message", I'll mention that it is possible to:

git commit --amend -m"New commit message" 

to change the commit message of a merge commit without losing the link to any of the parents of the merge commit.

like image 142
laszlok Avatar answered Oct 20 '22 18:10

laszlok