Skip to content

Instantly share code, notes, and snippets.

@median-man
Forked from adeekshith/.git-commit-template.txt
Last active September 19, 2024 14:09
Show Gist options
  • Save median-man/3a7c4324005e96f02691f3a20aeac26b to your computer and use it in GitHub Desktop.
Save median-man/3a7c4324005e96f02691f3a20aeac26b to your computer and use it in GitHub Desktop.
This commit message template helps you write **useful** commit messages.
# <type>: <subject> (Max 50 char, Why is this change necessary?)
# |<---- Using a Maximum Of 50 Characters ---->|
# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->|
# Explain how the commit addresses the issue
# IMPORTANT!! Describe any side effects of the change.
# Provide links or keys to any relevant tickets, articles or other resources
# Examples: "Jira issue [ABC-123]" or "Closes Github issue #123"
# --- COMMIT END ---
# Type can be
# feat (new feature)
# fix (bug fix)
# refactor (refactoring production code)
# style (formatting, missing semi colons, etc; no code change)
# docs (changes to documentation)
# test (adding or refactoring tests; no production code change)
# chore (updating grunt tasks etc; no production code change)
# wip (work in progress commit to be squashed -- do not push!)**
# --------------------
# Remember to
# - Capitalize the subject line
# - Use the imperative mood in the subject line
# - Do not end the subject line with a period
# - Separate subject from body with a blank line
# - Use the body to explain what and why vs. how
# - Can use multiple lines with "-" for bullet points in body.
# --------------------
# ** wip commit type
# A wip commit should only happen on a local branch. These commits are for
# unfinished snapshots that should not be checked into a shared branch.
# These commits should be squashed before changes are merged to
# a shared branch.
# --------------------
# For more information about this template and useful commit messages, check out
# - https://gist.github.com/median-man/3a7c4324005e96f02691f3a20aeac26b
# - https://gist.github.com/adeekshith/cd4c95a064977cdc6c50
# - https://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message
# - https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
# - https://8thlight.com/blog/kevin-liddle/2012/09/27/mind-your-git-manners.html
#
#

.gitmessage

This is the template I came up with to help me improve the quality of my commit messages by using a template.

Usage

Use as a default template: Better Commit Messages with a .gitmessage Template

Use in prepare-commit-msg git-hook: Atlassian: Git Hooks

Use as a template for a repository:

  1. Save the template in the repository as .gitmessage. (Use your own naming if you wish.)
  2. In your terminal, cd to the project root.
  3. Run git config commit.template '<path>/.gitmessage'. Replace path with the relative path to the directory for the template.
  4. Use git commit without the -m option to make a commit with the template.

Further Reading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment