Skip to content

Instantly share code, notes, and snippets.

@RickCogley
Last active June 17, 2025 01:26
Show Gist options
  • Save RickCogley/f0ce91bbdf7c9bf83f46d37f2a547eb7 to your computer and use it in GitHub Desktop.
Save RickCogley/f0ce91bbdf7c9bf83f46d37f2a547eb7 to your computer and use it in GitHub Desktop.
Awesome .gitmessage templates!

Awesome .gitmessage Templates!

In trying to figure out my own template for a .gitmessage template, I've collected up a couple of examples here.

It can be set with:

git config --global commit.template ~/.gitmessage

... and many git clients will pick it up and use it.

Note that, git commit's default behavior is to strip out commented lines, so just read the guide as you write the subject and body, leaving the template for git to delete.

# 0000000x000000000x000000000x000000000x0000000050
# 0000000x000000000x000000000x000000000x000000000x000000000x000000000x72
# Example: feat(auth): Implement user login flow
# Example: fix: Correct off-by-one error in pagination
# Example: docs: Update README with installation guide
# Example: chore: Update build dependencies
# Example: refactor: Extract common validation logic
#
# Example: feat(user-profile): Add avatar upload functionality
# ^type ^scope ^subject
#
# Adds an interface for users to upload and manage
# their profile avatars. Implements client-side validation
# and server-side storage.
#
# BREAKING CHANGE: User model 'profile_image_url' is now 'avatar_url'.
# Closes #999
#
# Header: <type>(<scope>): <subject>
# -------------------------------------------------------------------------------
# Type: (required)
# feat: A new feature
# fix: A bug fix
# 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
# build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
# ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
# chore: Other changes that don't modify src or test files
# revert: Reverts a previous commit
#
# Scope: (optional)
# What part of the codebase is affected? (e.g., 'auth', 'dashboard', 'API', 'UI', 'database', 'compiler')
#
# Subject: (required)
# - Use the imperative mood ("add", "change", "fix")
# - Max 72 characters
# - Don't capitalize first letter
# - No period at the end
# -------------------------------------------------------------------------------
#
# Body: (optional)
# - Explain the 'why' and 'how' of the change
# - Wrap lines at 72 characters
# -------------------------------------------------------------------------------
#
# Footer: (optional)
# - Reference issues (e.g., 'Closes #123', 'Fixes #456', 'Refs #789')
# - BREAKING CHANGE: (Mandatory for breaking changes - explains migration)
# -------------------------------------------------------------------------------
# feature: Add beta sequence.
# ^-----^ ^----------------^
# | |
# | +-> Summary in present tense sentence.
# |
# +-------> Type: binary, chore, doc, excise, feature, fix, hack, legal, refactor,
# style, or test.
#<type>[optional scope]: <description>
#fix|feat: do/did something
#[optional body]
#i made an awesome thing
#[optional footers]
#REF: INFRA-xxx
# Provide links to any relevant tickets, articles or other resources
# 50-character subject line
# 72-character wrapped longer description.
# ==== Template ====
# feat:
# A new feature
# fix:
# A bug fix
# 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 or correcting existing tests
# chore:
# Changes to the build process or auxiliary tools and libraries such as documentation generation
# ==== Format ====
#
# Commit body...
# ==== The Seven Rules ====
# 1. Separate subject from body with a blank line
# 2. Limit the subject line to 50 characters
# 3. Capitalize the subject line
# 4. Do not end the subject line with a period
# 5. Use the imperative mood in the subject line
# 6. Wrap the body at 72 characters
# 7. Use the body to explain what and why vs. how
#
# How to Write a Git Commit Message http://chris.beams.io/posts/git-commit/
# for http://memo.goodpatch.co/2016/07/beautiful-commits-with-emojis/
# <type>: (If applied, this commit will...) <subject> (Max 50 char)
# |<---- Using a Maximum Of 50 Characters ---->|
# Explain why this change is being made
# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->|
# Provide links or keys to any relevant tickets, articles or other resources
# Example: Github issue #23
# --- COMMIT END ---
# Type can be
# feat (new feature)
# fix (bug fix)
# docs (changes to documentation)
# style (formatting, missing semi colons, etc; no code change)
# refactor (refactoring production code)
# test (adding missing tests, refactoring tests; no production code change)
# chore (updating grunt tasks etc; no production code change)
# --------------------
# Remember to
# Separate subject from body with a blank line
# Limit the subject line to 50 characters
# Capitalize the subject line
# Do not end the subject line with a period
# Use the imperative mood in the subject line
# Wrap the body at 72 characters
# Use the body to explain what and why vs. how
# Can use multiple lines with "-" for bullet points in body
# --------------------
# For more information about this template, check out
# https://gist.github.com/bsed/55c571ea7943043fba80913e905a2fdb
# git config --global commit.template ~/.gitmessage
# https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines
#
# <subject> and <body>:
# - use the imperative, present tense: "change" not "changed" nor "changes".
# - no capitalization of first letter
# - no punctuation
#
# If applied this change will <subject>
<type>(<scope>): <subject>
# feat(scope): Short description (max 50-72 chars)
#
# (Optional) Longer body explaining why this change was made,
# what problem it solves, and how it was implemented.
# Wrap lines at 72 characters.
#
# BREAKING CHANGE: Describe breaking changes here.
#
# Closes #123, Fixes #456
# Co-authored-by: Name <[email protected]>
# <type>(<scope>): <subject>
#
# Body (optional)
#
# Footer (optional)
#
# Example: feat(auth): Implement user login flow
# Example: fix: Correct off-by-one error in pagination
# Example: docs: Update README with installation guide
# Example: chore: Update build dependencies
# Example: refactor: Extract common validation logic
#
# Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
# Scope: (optional) Context for the change (e.g., auth, user-profile, database, api)
# Subject: Imperative, short description (max ~72 chars)
# Body: Explain the 'why' and 'how'. Wrap at ~72 chars.
# Footer: Reference issues (e.g., Closes #123, Fixes #456), BREAKING CHANGE:
# Conventional Commit Message
#
# Header: <type>(<scope>): <subject>
# -------------------------------------------------------------------------------
# Type: (required)
# feat: A new feature
# fix: A bug fix
# 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
# build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
# ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
# chore: Other changes that don't modify src or test files
# revert: Reverts a previous commit
#
# Scope: (optional)
# What part of the codebase is affected? (e.g., 'auth', 'dashboard', 'API', 'UI', 'database', 'compiler')
#
# Subject: (required)
# - Use the imperative mood ("add", "change", "fix")
# - Max 72 characters
# - Don't capitalize first letter
# - No period at the end
# -------------------------------------------------------------------------------
#
# Body: (optional)
# - Explain the 'why' and 'how' of the change
# - Wrap lines at 72 characters
# -------------------------------------------------------------------------------
#
# Footer: (optional)
# - Reference issues (e.g., 'Closes #123', 'Fixes #456', 'Refs #789')
# - BREAKING CHANGE: (Mandatory for breaking changes - explains migration)
# -------------------------------------------------------------------------------
#
# Example: feat(user-profile): Add avatar upload functionality
# ^type ^scope ^subject
#
# Adds an interface for users to upload and manage
# their profile avatars. Implements client-side validation
# and server-side storage.
#
# BREAKING CHANGE: User model 'profile_image_url' is now 'avatar_url'.
# Closes #999
# Type: feat | fix | docs | style | refactor | perf | test | build | ci | chore | revert
# Scope: (optional, e.g., auth, ui, api, db, feature-name)
#
# --- Begin your commit message below this line ---
#
# feat(scope): Short description of new feature (max ~72 chars)
#
# OR
#
# fix(scope): Short description of bug fix (max ~72 chars)
#
# (Optional) Detailed explanation of the change.
# What problem does this solve? How was it fixed/implemented?
# Why was this particular approach chosen?
#
# Wrap lines at 72 characters.
#
# (Optional) Footer - for breaking changes or issue references.
# BREAKING CHANGE: Brief description of breaking change and migration guide.
# Closes #123, Fixes #456, Relates-to: #789
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment