Skip to content

Instantly share code, notes, and snippets.

@syhe
Created January 19, 2023 17:36
Show Gist options
  • Save syhe/19aa2d7ff6bedadc6932c5523f64cca8 to your computer and use it in GitHub Desktop.
Save syhe/19aa2d7ff6bedadc6932c5523f64cca8 to your computer and use it in GitHub Desktop.
Git Commit Template

Git commit template

Git commit template to improve your project's commit messages.

This commit template has a bunch of information inside, and it's set up so you can freely edit it as you like.

If you want to learn why we use this kind of template, see our repo How to write a great git commit message

If you want to improve your git speed and capabilities, see our repo Git alias configuration for shortcuts and enhancements

Help

Subject line imperative uppercase verbs:

  • Add = Create a capability e.g. feature, test, dependency.
  • Drop = Delete a capability e.g. feature, test, dependency.
  • Fix = Fix an issue e.g. bug, typo, accident, misstatement.
  • Bump = Increase the version of something e.g. a dependency.
  • Make = Change the build process, or tools, or infrastructure.
  • Start = Begin doing something; e.g. enable a toggle, feature flag, etc.
  • Stop = End doing something; e.g. disable a toggle, feature flag, etc.
  • Optimize = A change that MUST be just about performance, e.g. speed up code.
  • Document = A change that MUST be only in the documentation, e.g. help files.
  • Refactor = A change that MUST be just refactoring.
  • Reformat = A change that MUST be just format, e.g. indent line, trim space, etc.
  • Rephrase = A change that MUST be just textual, e.g. edit a comment, doc, etc.

For the subject line:

  • Use 50 characters maximum.
  • Do not use a sentence-ending period.

For the body text:

  • Use as many lines as you like.
  • Use 72 characters maximum per line for typical word wrap text.

Usage

Put the template file here:

 ~/.git_commit_template.txt

Configure git to use the template file by running:

 git config --global commit.template ~/.git_commit_template.txt

Add the template file to our ~/.gitconfig file:

[commit]
  template = ~/.git_commit_template.txt

If you prefer other file locations or ways of working, you can freely adjust the usage as you like.

Tracking

  • Package: git_commit_message
  • Version: 6.0.2
  • Updated: 2018-08-27T22:15:57Z
  • Licence: GNU General Public License (GPL-3.0)
  • Contact: Joel Parker Henderson (http://joelparkerhenderson.com)
# <type>[(scope)][!]: <description>
#
# Why is this change happening, e.g. goals, use cases, stories, etc.?
# How is this change happening, e.g. implementations, algorithms, etc.?
# What are the side effects external to this project?
#
# See links to relevant web pages, issue trackers, blog articles, etc.
# See: https://example.com/
# See: [Example Page](https://example.com/)
#
# List all co-authors, so version control systems can connect teams.
# Co-authored-by: Name <[email protected]>
#
# Bitbucket transition: .* <ISSUE-KEY>+ .* #<transition_name> <comment_string>
# Bitbucket comment: .* <ISSUE-KEY>+ .* #comment <comment_string>
# Bitbucket time: .* <ISSUE-KEY>+ .* #time [0-9]+w [0-9]+d [0-9]+h [0-9]+m <comment_string>
#
# BREAKING CHANGE: a commit that has a footer BREAKING CHANGE: <description>,
# or appends a ! after the type/scope, introduces a breaking API change. (MAJOR)
# Subject line types:
# fix: a commit of the type fix patches a bug in your codebase. (PATCH)
# feat: a commit of the type feat introduces a new feature to the codebase. (MINOR)
# build: Changes that affect the build system or external dependencies
# ci: Changes to our CI configuration files and scripts
# docs: Documentation only changes
# style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
# refactor: A code change that neither fixes a bug nor adds a feature
# perf: A code change that improves performance
# test: Adding missing tests or correcting existing tests
# revert: <header of reverted commit> In the body it should say: This reverts commit <hash>.
# Subject line imperative uppercase verbs:
# Add = Create a capability e.g. feature, test, dependency.
# Drop = Delete a capability e.g. feature, test, dependency.
# Fix = Fix an issue e.g. bug, typo, accident, misstatement.
# Bump = Increase the version of something e.g. a dependency.
# Make = Change the build process, or tools, or infrastructure.
# Start = Begin doing something; e.g. enable a toggle, feature flag, etc.
# Stop = End doing something; e.g. disable a toggle, feature flag, etc.
# Optimize = A change that MUST be just about performance, e.g. speed up code.
# Document = A change that MUST be only in the documentation, e.g. help files.
# Refactor = A change that MUST be just refactoring.
# Reformat = A change that MUST be just format, e.g. indent line, trim space, etc.
# Rephrase = A change that MUST be just textual, e.g. edit a comment, doc, etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment