PullNotifier Logo

PullNotifier

Git Commit Message Guide

A well-crafted git commit message is the best way to communicate context about a change to your team and your future self. Great commit messages make your project history readable, your code reviews faster, and your debugging sessions shorter. Below you'll find free git commit message templates you can copy and use immediately, a comprehensive guide to writing effective commit messages, and an interactive validator to check your messages against best practices. Whether you're looking for a git commit message template for your team or learning the conventions for the first time, this page has everything you need.


Table of Contents

1. Standard Commit Message Template2. Conventional Commits Template3. Minimal Team Template4. Bug Fix Commit Template5. Feature Commit Template6. What Is a Git Commit Message?7. The 7 Rules of Great Git Commit Messages8. Commit Message Validator9. Conventional Commits10. Good vs Bad Commit Messages11. How to Set Up a Git Commit Message Template12. Git Commit Message Tools13. Commit Messages and Pull Requests14. FAQ

Other Tools

Stacked PRs GuideCode Coverage GuideMerge Request vs Pull RequestIntegrate GitLab with SlackSlack GitHub Actions
See all tools โ†’
PullNotifier โ€” Pull request alerts directly on Slack

Standard Commit Message Template

The classic .gitmessage template file with commented guidelines. Save this as ~/.gitmessage and configure Git to use it automatically.


Conventional Commits Template

Follows the Conventional Commits specification (v1.0.0). Pairs well with semantic-release and automated changelogs.


Minimal Team Template

A lightweight commit message template for small teams who want structure without overhead.


Bug Fix Commit Template

A specialized template for bug fix commits that captures root cause and verification details.


Feature Commit Template

A specialized template for feature commits that provides context on the motivation and scope.


What Is a Git Commit Message?

A git commit message is a short description attached to each commit in a Git repository. It records why a change was made and provides context for anyone reading the project history โ€” whether that's a teammate reviewing a pull request, a future developer investigating a bug, or your future self trying to understand code you wrote six months ago.

Every git commit message has up to three parts:

  1. Subject line โ€” A brief summary of the change (50 characters max). This is the only mandatory part and is what most tools display in logs and history views.
  2. Body โ€” An optional longer explanation of what changed and why. Separated from the subject by a blank line and wrapped at 72 characters.
  3. Footer โ€” Optional metadata like issue references (Closes #123), co-authors, or breaking change notices.

Well-written commit messages transform your git log from an opaque list of diffs into a readable narrative of how your project evolved. They are one of the highest-leverage habits a developer can adopt.


The 7 Rules of Great Git Commit Messages

These rules, popularized by Chris Beams, are widely considered the standard for writing git commit messages. Follow them and your project history will be clean, consistent, and useful.

  1. Separate subject from body with a blank line.

    Many Git tools treat the first line as the subject and everything after the blank line as the body. Without the blank line, commands like git log --oneline and git shortlog won't work correctly.
  2. Limit the subject line to 50 characters.

    This keeps the subject readable in git log, GitHub's commit list, and other tools. If you can't summarize the change in 50 characters, the commit may be doing too much.
  3. Capitalize the subject line.

    Begin the subject with a capital letter. This is a simple convention that makes the history look clean and professional.
  4. Do not end the subject line with a period.

    Trailing punctuation is unnecessary in a subject line. Space is precious when you're limited to 50 characters.
  5. Use the imperative mood in the subject line.

    Write as if you're giving a command: "Add feature", "Fix bug", "Remove deprecated method". A properly formed subject should complete the sentence: "If applied, this commit will your subject line."
  6. Wrap the body at 72 characters.

    Git doesn't wrap text automatically. Wrapping at 72 characters ensures the body is readable in terminal windows and tools that display commit messages.
  7. Use the body to explain what and why, not how.

    The code diff shows how the change was made. The commit message should explain what motivated the change and why this approach was chosen over alternatives.

Commit Message Validator

Type a commit message below to check it against the rules above. The validator provides real-time feedback on your subject line and body formatting.

Subject line

0/50

Body (optional)

Validation

โ—‹

Subject line โ‰ค 50 characters

โ—‹

Capitalized subject line

โ—‹

No trailing period in subject

โ—‹

Imperative mood

โ—‹

Blank line between subject and body

โ—‹

Body lines โ‰ค 72 characters


Conventional Commits

Conventional Commits is a specification that adds structure to commit messages by requiring a type prefix. The format is type(scope): description. This convention enables automated tooling โ€” changelog generation, semantic versioning, and release automation โ€” and makes commit history easy to scan.

TypeDescriptionSemVerExample
featA new featureMINORfeat(auth): Add SSO login
fixA bug fixPATCHfix(api): Handle null user response
docsDocumentation changesโ€”docs: Update API reference
styleFormatting, no code changeโ€”style: Fix indentation in utils
refactorCode change, no new feature or fixโ€”refactor: Extract auth middleware
perfPerformance improvementPATCHperf: Cache database queries
testAdding or fixing testsโ€”test: Add unit tests for parser
buildBuild system or dependenciesโ€”build: Upgrade webpack to v5
ciCI configuration changesโ€”ci: Add GitHub Actions workflow
choreMaintenance tasksโ€”chore: Update .gitignore

To indicate a breaking change, add ! after the type (e.g., feat!: Remove v1 API) or include a BREAKING CHANGE: footer in the commit body. Breaking changes correlate with a MAJOR version bump in SemVer.


Good vs Bad Commit Messages

The difference between a helpful and unhelpful commit message is often obvious in hindsight. Here are side-by-side examples:

BadGoodWhy
fix bugFix race condition in session cleanupSpecificity โ€” "fix bug" gives no context for debugging
updated stuffUpdate payment gateway to Stripe API v3Imperative mood and specific scope
asdfghAdd input validation for email fieldMeaningful description vs. keyboard mashing
WIPAdd draft implementation of user searchEven in-progress work should be described
fixed the thing that john broke last tuesday when he pushed the change to the auth moduleFix token expiry check in auth middlewareConcise, blameless, under 50 characters
changes.Refactor user service to use repository patternDescribes the change and the approach
Added feature and also fixed some bugs and updated depsSplit into 3 separate commitsOne commit should do one thing โ€” atomic commits

How to Set Up a Git Commit Message Template

Git supports commit message templates natively. When configured, the template appears in your editor every time you run git commit (without the -m flag), giving you a consistent starting point.

  1. Create the template file.

    Save one of the templates above to a file โ€” for example, ~/.gitmessage. Lines starting with # are comments and won't appear in the final commit message.
  2. Configure Git to use it globally.

    Run: git config --global commit.template ~/.gitmessage. This tells Git to use your template for all repositories.
  3. For a single project only.

    Run the same command without --global from inside the repository: git config commit.template .gitmessage. This is useful when different projects have different conventions.
  4. Commit as usual.

    Run git commit (without -m). Your editor will open with the template pre-filled. Write your message, save, and close the editor.

For teams, commit the template file to your repository (e.g., as .gitmessage at the root) and add the setup command to your onboarding documentation.


Git Commit Message Tools

These tools help teams enforce commit message conventions automatically:

  • Commitizen โ€” An interactive CLI that prompts you to fill in commit message fields step by step. Ensures every commit follows the Conventional Commits format. Install with npm install -g commitizen and use git cz instead of git commit.
  • Commitlint โ€” A linter for commit messages. Runs as a Git hook and rejects commits that don't match your configured rules. Commonly paired with Husky to run automatically on every commit.
  • Husky โ€” A tool for managing Git hooks. Use it to run Commitlint on the commit-msg hook, ensuring every commit message is validated before it's accepted.
  • Gitmoji โ€” Adds emoji prefixes to commit messages for visual categorization (e.g., โœจ for new features, ๐Ÿ› for bug fixes). Popular in open-source projects for making commit logs scannable at a glance.
  • semantic-release โ€” Automates versioning and changelog generation based on Conventional Commits. When your commit messages follow the convention, semantic-release can determine the next version number and publish a release automatically.

Commit Messages and Pull Requests

How commit messages interact with pull requests depends on your merge strategy. Understanding this relationship helps you decide where to invest effort in writing good messages.

  • Merge commit โ€” All individual commits are preserved. Each commit message matters because they all appear in the main branch history. This strategy requires discipline in writing good messages throughout development, not just at merge time.
  • Squash and merge โ€” All commits in the PR are squashed into a single commit. GitHub defaults the squash message to the PR title and description. With this strategy, the PR title becomes the most important message โ€” it's what appears in git log.
  • Rebase and merge โ€” Individual commits are rebased onto the target branch. Like merge commits, each commit message is preserved. This strategy produces the cleanest linear history but requires well-written individual commits.

Use auto-close keywords in your commit messages or PR descriptions to link changes to issues: Closes #123, Fixes #456, Resolves #789. GitHub will automatically close the referenced issue when the commit is merged to the default branch.

Good commit messages make code reviews faster. When a reviewer can read the commit message and understand the intent before looking at the diff, the review focuses on correctness and design rather than trying to understand what the change does. Tools like PullNotifier send GitHub pull request notifications to Slack, keeping your team informed about PRs that need review, merges, and CI status โ€” closing the loop between commit messages and team communication.


FAQ

What is a good git commit message?

A good git commit message is concise (50 characters or fewer for the subject), uses imperative mood ("Add feature" not "Added feature"), starts with a capital letter, omits trailing periods, and explains the why behind the change. If the change is non-trivial, include a body wrapped at 72 characters that provides additional context.

How long should a git commit message be?

The subject line should be 50 characters or fewer. If you include a body, separate it from the subject with a blank line and wrap each line at 72 characters. There is no hard limit on the body length โ€” include as much context as needed to explain the change.

What is Conventional Commits?

Conventional Commits is a specification for structuring commit messages in the format "type(scope): description". Types include feat, fix, docs, style, refactor, test, and chore. This convention enables automated changelog generation, semantic versioning, and makes commit history easier to parse. It is widely adopted in open-source and enterprise projects.

How do I set up a git commit message template?

Create a template file (e.g., ~/.gitmessage) with your preferred format and comments, then run "git config --global commit.template ~/.gitmessage". Git will use this template every time you run "git commit" without the -m flag. You can also set project-specific templates by omitting --global.

Should I use past tense or imperative mood in commit messages?

Use imperative mood โ€” "Add feature", "Fix bug", "Remove deprecated method". This matches the convention used by Git itself (e.g., "Merge branch", "Revert commit") and reads as a command: "If applied, this commit will [your subject line]." Avoid past tense ("Added", "Fixed") and present participle ("Adding", "Fixing").

What is the difference between a commit message subject and body?

The subject is the first line of the commit message โ€” a brief summary of the change (50 characters max). The body is optional additional text separated from the subject by a blank line. The body explains what changed and why, wrapped at 72 characters. Many tools (GitHub, git log --oneline) only show the subject, so it must stand on its own.


Related resources: Pull Request Templates ยท Code Review Checklist


Other Tools

See all tools โ†’
PullNotifier โ€” Pull request alerts directly on Slack
PullNotifier Logo

PullNotifier

ยฉ 2026 PullNotifier. All rights reserved