← Back to Blog

Prefixing Git Commits with Commit Templates

Problem

In engineering teams, commits are often tracked by prefixing them with a project ticket key (e.g. PSG-5003-FixLongRunningQuery). It is easy to forget to add this ticket prefix manually.

Rather than configuring complex git hooks across repositories, you can use a custom git commit message template in .git/config.

Step 1: Append Template Reference in .git/config

In your_repo/.git/config, add the following section:

[commit]
template = .git/.gitmessage.txt

Step 2: Fill in the Prefix File

Create .git/.gitmessage.txt and insert your default ticket prefix:

PSG-

Now, every time you run git commit, your commit message editor will automatically load with PSG- pre-filled.