GitLab: How to change merge commit message template?

Viewed 3707

Typical message looks like:

Merge branch ‘mass-refactoring’ into ‘master’

Mass refactoring

See merge request group/project!13

Is it possible to change template to something like: ?

HEADER

BODY

Merge branch SRC_BRANCH into TGT_BRANCH. See merge-request GROUP/PROJECT!N
2 Answers

As listed here (gitlab issue #2551) the wish for such a feature is still present (4 weeks ago).

To answer your question, no, there is none built-in gitlab feature to change the merge message template.

GitLab 14.5 (November 2021) should implement that feature:

Merge commit message template

Merge commits can provide important context to the commit history of a project about what was merged.
However, if you don’t edit the merge commit prior to merging, other users are forced to navigate to a merge request to gain additional context about why the changes were made.

Project maintainers can now configure a default merge commit message template.

This allows projects to specify a standard merge commit, and use variables to provide additional details in these messages.
This additional context helps the next developer when trying to understand why the change was made, by providing the potential to make all the relevant information available in the merge commit.

Thanks to Piotr for this amazing contribution!

https://about.gitlab.com/images/14_5/create-code-review-merge-commit-template.png -- Merge commit message template

See Documentation and Issue.


With GitLab 14.6 (December 2021), you even have:

Squash commit message template

Squashing commits is a great way to clean up the commit history of a merge request by combining all commits when merging. Branch history becomes easier to read and follow, while the story behind the changes remains intact. GitLab previously used the merge request title as the default squash commit message. If you didn’t edit the message before merging, important details about the change could be lost.

Project maintainers can now customize the default squash commit message according to the project needs. Include details about each merge request, like the source and target branches, with helpful variables. With more complete squash commit messages, everyone can now better understand the context of the changes.

Thanks to Piotr for this amazing contribution!

https://about.gitlab.com/images/14_6/create-code-review-squash-commit-template.png -- Squash commit message template

See Documentation and Issue.

Related