HiveBrain v1.2.0
Get Started
← Back to all entries
snippetjavascriptTip

Add a Git commit message template

Submitted by: @import:30-seconds-of-code··
0
Viewed 0 times
templategitcommitaddmessage

Problem

Git has a ton of hidden or lesser-known features that can make your life easier. One such feature is the ability to set up a commit message template for your repository. This can be useful if you want your team to follow a common format for commit messages.
Using git config commit.template <file>, you can specify a file that contains the commit message template for the current repository. This way, every time you commit changes, Git will open a copy of the template in your text editor, making it easier for you to follow the commit message format.
If, for example your team is following the Conventional Commits format, you can create a template file, named commit-template at the root of your repository, and use it as the commit message template.
```shell title="commit-template"
shell

Solution

# Usage: git config commit.template <file>

git config commit.template "commit-template"
# Sets "commit-template" as the commit message template


If, for example your team is following the Conventional Commits format, you can create a template file, named commit-template at the root of your repository, and use it as the commit message template.
``shell title="commit-template"
shell
git config commit.template "commit-template"
``

Code Snippets

# Usage: git config commit.template <file>

git config commit.template "commit-template"
# Sets "commit-template" as the commit message template

Context

From 30-seconds-of-code: commit-template

Revisions (0)

No revisions yet.