9

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
kyb
  • 7,233
  • 5
  • 52
  • 105
  • [GitLab 15.7, Dec. 2022](https://stackoverflow.com/a/70069905/6309) adds variables like `%{source_branch}` and `%{target_branch}`. – VonC Dec 24 '22 at 10:33

2 Answers2

4

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.

YesThatIsMyName
  • 1,585
  • 3
  • 23
  • 30
  • That ticket is for editing commit messages of individual commits that are being merged when merging. Not for a configurable template that will pre-fill merge commit messages which the question refers to. – Kissaki Jun 04 '19 at 08:11
4

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.


GitLab 15.7 (December 2022) adds variable:

Variables in merge request description templates

When creating a merge request, your organization may define merge request templates.
These templates help make sure certain information is filled in, provide checklists for tasks, and more.

However, they don’t contain any Git-level information that may be important for the merge request.
This can make it challenging to provide commit message details, branch information, or even author information in a standardized and repeatable way.

Merge request description templates now support variables.

Use these variables to build both business logic and important Git information, like commit and authoring info, into merge requests.
Template variables ensure incoming merge requests always include the information your project requires, without tedious manual effort from contributors.

Thanks to David Barr for contributing this!

https://about.gitlab.com/images/15_7/create-code-review-mr-desc-template-variables.png -- Variables in merge request description templates

See Documentation and Issue.

In your case, %{source_branch} and %{target_branch} are of interest.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250