0

Is there a way to use the global/local commit message template for merge commits ? I have a commit message template that gets used for all the non-merge commits.

I invoke the git merge command as below: git merge --no-ff --edit dev

This brings up the editor with the default git merge message. Would it be possible to populate the editor with the global/local commit message template as in the case of other commits ?

Also, is there a way to do that for the merge commits that happen as part of the git pull operation ? Git pull usually creates merge commits if there is a need and the message put into these merge commits is the default one. I would need my users key in their comments as per the local/global commit message template.

Any thoughts ?

SoDa
  • 71
  • 2
  • 8
  • I am not sure what you mean by "global/local commit message template": do you mean the `git config commit.template` setting? In any case, (2) the merge made by `git pull` is made by actually running `git merge` (or was before the Windows people started converting the shell scripts to C code, who knows what it does now :-) ), which gets us to (1), the default merge message from `git merge`: unfortunately there is no config option for this, just the `-m` argument. There is also `git fmt-merge-message` but it behave similarly (and `git merge` does not run it separately). – torek May 23 '16 at 23:00
  • Yes, you got it right. I meant the "git config commit.template" setting by "global/local commit message template". So there seems to be no way to populate the commit message template contents in the git merge message other than specifying it manually using -m or using --edit to bring up the editor and then modifying it :( – SoDa May 23 '16 at 23:41
  • Pretty much, yes. Write your own little script and use that instead of `git merge`, maybe via alias `git mymerge`; and never use `git pull` (run `git fetch` and `git mymerge` yourself, if you want merges; or `git fetch` and `git rebase`, if you want rebasing). – torek May 23 '16 at 23:46

0 Answers0