A useful template for commit messages

Here’s a useful heuristic for writing better commit messages. Set your commit message template to:

# If applied, this commit will...

# Explain why this change is being made

# Provide links to any relevant tickets, articles or other resources

and you’ll be guided into writing concise commit subjects in the imperative mood - a good practice. See rule 5 of Chris Beam’s “How to write a commit message” for the inspiration of this tip and more reasoning on the use of the imperative mood.

To do this in Git, save the above content in a file (eg ~/.git_commit_msg.txt) and run:

$ git config --global commit.template ~/.git_commit_msg.txt

Here’s what this looks like in practice:

Try it - it’s genuinely useful.

----

Tagged with: git
Filed in: tips
Revision history

Previous: Copying Postgres output into a spreadsheet
Next: Octopus Energy

Copyright © 2005-2017 David Winterbottom
Content licensed under CC BY-NC-SA 4.0.