Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitLab: How to change merge commit message template?

Tags:

git

gitlab

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
like image 922
kyb Avatar asked Oct 23 '18 19:10

kyb


People also ask

How do I change a merge commit message?

You can change the most recent commit message using the git commit --amend command. In Git, the text of the commit message is part of the commit. Changing the commit message will change the commit ID--i.e., the SHA1 checksum that names the commit. Effectively, you are creating a new commit that replaces the old one.

How do you change the commit message in GitLab?

Changing the latest Git commit message If the message to be changed is for the latest commit to the repository, then the following commands are to be executed: git commit --amend -m "New message" git push --force repository-name branch-name.


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.

like image 137
YesThatIsMyName Avatar answered Oct 21 '22 18:10

YesThatIsMyName


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.

like image 38
VonC Avatar answered Oct 21 '22 17:10

VonC