Commit Message Templates
We set something up on a recent project that I really liked.
In the midst of writing a bunch of tests, I realized I was starting every commit message with Test
, followed by a description of the feature. Test login
, Test that bots are redirected
, etc. Typing the same word over and over is redundant, and it adds up quickly.
We paused and set up a commit template for the project.
Here's the file we made (~/.git_commit_template
):
Test
And the command in the project directory:
$ git config commit.template ~/.git_commit_template
Our next commit message started with Test
, so we just used CTRL-A
to jump to the end of the sentence and start filling it in.
This does more than just save keystrokes. It reminds us that we have a format we want to stick to, and helps keep our commit message more uniform.
This could also be set globally, if you have a format you prefer to use on every project.
Tweet