Git Commit Message Format: The Complete Reference
2026-10-11
# Git Commit Message Format: The Complete Reference
Ever opened a git log and felt like you were reading a foreign language? Inconsistent formats, vague descriptions, no structure — it's a common problem that makes codebases harder to maintain.
The solution is simple: adopt a standard commit message format. In this guide, you'll learn the Conventional Commits format (the most widely adopted standard), get copy-paste templates, see examples for every type of change, and discover how to enforce the format across your team.
The Conventional Commits Format
Conventional Commits is a lightweight specification for commit messages. It provides a simple set of rules for creating a clear commit history.
The Structure
```
```
- type: The category of change (required)
- scope: The area of the codebase affected (optional)
- subject: A short description of the change (required)
- body: Additional context (optional)
- footer: Metadata like issue references or breaking changes (optional)
Type Reference Table
| Type | Description | Example |
|------|-------------|---------|
| `feat` | A new feature | `feat(auth): add SSO login` |
| `fix` | A bug fix | `fix(cart): correct tax calculation` |
| `docs` | Documentation only | `docs(readme): add install steps` |
| `style` | Code style (no logic change) | `style(lint): fix semicolon errors` |
| `refactor` | Code change (not feat or fix) | `refactor(api): extract validation` |
| `perf` | Performance improvement | `perf(query): add database index` |
| `test` | Adding or fixing tests | `test(auth): add login flow tests` |
| `build` | Build system or dependencies | `build(deps): upgrade webpack to v5` |
| `ci` | CI configuration changes | `ci(github): add deploy workflow` |
| `chore` | Other maintenance | `chore(gitignore): add .env.local` |
| `revert` | Reverting a commit | `revert: feat(auth): add SSO login` |
Breaking Changes
If your commit introduces a breaking change, indicate it in the footer or with a `!` after the type/scope:
```
feat(api)!: change user endpoint response format
BREAKING CHANGE: The /api/users endpoint now returns an array
instead of an object with a data property. Update all clients
to handle the new response format.
```
Or more concisely:
```
feat(api)!: change user endpoint response format
```
The `!` signals a breaking change at a glance.
Commit Message Template
Here's a copy-paste template you can use for your commits:
```
```
Quick Reference: When to Use Each Type
- feat: Use when adding new functionality visible to users
- fix: Use when correcting incorrect behavior
- docs: Use when updating README, API docs, inline comments
- style: Use for formatting, missing semicolons, whitespace (no logic change)
- refactor: Use when restructuring code without changing behavior
- perf: Use when improving performance (measure before and after!)
- test: Use when adding missing tests or correcting existing tests
- build: Use for changes to build scripts, dependencies, or tooling
- ci: Use for changes to CI/CD configuration (GitHub Actions, CircleCI, etc.)
- chore: Use for miscellaneous tasks that don't fit other categories
Format Examples by Change Type
Feature Commits
```
feat(user): add profile picture upload
Users can now upload a profile picture from their settings page.
Supports JPEG and PNG formats, max 5MB. Images are resized to
256x256 and stored in S3.
Closes #234
```
```
feat(search): add full-text search with filters
Implemented full-text search across products with filters for
category, price range, and rating. Uses PostgreSQL tsvector for
fast query performance.
Closes #567
```
Bug Fix Commits
```
fix(payment): handle expired credit cards gracefully
Previously, expired cards caused a 500 error during checkout.
Now we catch the Stripe error and show a user-friendly message
asking for updated payment information.
Fixes #890
```
```
fix(auth): prevent session fixation attacks
Regenerate session ID after successful login to prevent session
fixation. Added secure flag to session cookies in production.
Fixes #345
```
Documentation Commits
```
docs(api): add authentication examples
Added code examples for all authentication endpoints:
- Login with email/password
- Login with OAuth
- Refresh token
- Logout
Closes #123
```
Refactoring Commits
```
refactor(api): extract validation logic into separate module
Moved request validation from route handlers into a dedicated
validator module. This improves testability and reduces code
duplication across endpoints.
No behavior changes. All existing tests pass.
```
Performance Commits
```
perf(query): add database index for user lookups
Added composite index on (email, tenant_id) for user authentication
queries. Reduces query time from 450ms to 12ms.
Benchmark: 1000 concurrent logins, p95 latency reduced from 800ms to 45ms.
```
Test Commits
```
test(auth): add integration tests for OAuth flow
Added end-to-end tests for Google and GitHub OAuth flows:
- Successful login
- Account linking
- Error handling for expired tokens
- Callback URL validation
Coverage for auth module: 67% → 89%
```
Enforcing Format on Your Team
Consistency requires enforcement. Here are three tools that make it easy.
1. Commitlint
Commitlint checks if your commit messages follow a standard format.
Installation:
```bash
npm install --save-dev @commitlint/cli @commitlint/config-conventional
```
Configuration (commitlint.config.js):
```javascript
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [2, 'always', [
'feat', 'fix', 'docs', 'style', 'refactor',
'perf', 'test', 'build', 'ci', 'chore', 'revert'
]],
'subject-case': [2, 'always', 'lower-case'],
'subject-max-length': [2, 'always', 72],
],
};
```
2. Husky
Husky runs Git hooks. Combine it with Commitlint to check messages before they're committed.
Installation:
```bash
npm install --save-dev husky
npx husky install
```
Add commit-msg hook:
```bash
npx husky add .husky/commit-msg 'npx --no -- commitlint --edit “$1”'
```
Now every commit is checked. If the message doesn't follow the format, the commit is rejected.
3. AI Commit Generators
Even with enforcement, writing good messages takes effort. AI commit generators can help by analyzing your staged changes and suggesting messages that follow your team's format.
The Git Commit Message Generator generates Conventional Commits format messages automatically. Paste your `git diff` and get a clear, consistent message in seconds. You can edit before committing, but the structure is always correct.
Putting It All Together
1. Define your format (Conventional Commits is a good default)
2. Add Commitlint to check messages automatically
3. Add Husky to run Commitlint on every commit
4. Use AI tools to generate suggestions and maintain consistency
5. Review in PRs — catch anything that slips through
Related Articles
- How to Write Better Git Commit Messages
- Conventional Commits Best Practices
- Why Your Team Needs Conventional Commits
---
*Need help writing commit messages in the right format? Try the Git Commit Message Generator — it generates Conventional Commits format messages automatically from your changes.*