This document defines commit message conventions following the Conventional Commits specification with emoji prefixes.
<emoji> <type>[optional scope]: <description>
[optional body]
[optional footer(s)]
β¨ feat: add user authentication feature
π fix(auth): resolve session management bug during login
π docs: update API documentation
π₯ feat(api)!: send email to customer when product is shipped
Emoji | GitHub Code | Type | Description | Example |
---|---|---|---|---|
β¨ | :sparkles: |
feat |
A new feature | β¨ feat: add dark mode toggle |
π | :bug: |
fix |
A bug fix | π fix: resolve null pointer exception |
π | :books: |
docs |
Documentation only changes | π docs: update installation guide |
π¨ | :art: |
style |
Changes that don't affect code meaning (formatting, etc.) | π¨ style: format code with prettier |
β»οΈ | :recycle: |
refactor |
Code change that neither fixes a bug nor adds a feature | β»οΈ refactor: extract auth logic into service |
β‘ | :zap: |
perf |
Performance improvements | β‘ perf: lazy load images |
β | :white_check_mark: |
test |
Adding or correcting tests | β
test: add unit tests for user service |
ποΈ | :building_construction: |
build |
Changes to build system or dependencies | ποΈ build: update webpack to v5 |
π· | :construction_worker: |
ci |
Changes to CI configuration files and scripts | π· ci: add GitHub Actions workflow |
π§Ή | :broom: |
chore |
Other changes that don't modify src or test files | π§Ή chore: update .gitignore |
βͺ | :rewind: |
revert |
Reverts a previous commit | βͺ revert: revert commit abc123 |
Emoji | GitHub Code | Type | Description | Example |
---|---|---|---|---|
π | :lock: |
security |
Security improvements or fixes | π security: patch XSS vulnerability |
β¬οΈ | :arrow_up: |
deps |
Dependency updates | β¬οΈ deps: upgrade React to v18 |
π§ | :wrench: |
config |
Configuration changes | π§ config: update ESLint rules |
π·οΈ | :label: |
release |
Release/version related changes | π·οΈ release: bump version to 1.2.0 |
π | :ambulance: |
hotfix |
Critical hotfix | π hotfix: fix production crash |
π | :lipstick: |
ui |
UI/UX improvements | π ui: improve button styling |
π | :globe_with_meridians: |
i18n |
Internationalization | π i18n: add Japanese translations |
βΏ | :wheelchair: |
a11y |
Accessibility improvements | βΏ a11y: add screen reader support |
πΈ | :camera_flash: |
snapshot |
Update snapshots | πΈ snapshot: update test snapshots |
π§ͺ | :test_tube: |
experiment |
Experimental changes | π§ͺ experiment: try new algorithm |
Scope provides additional contextual information and should be a noun describing a section of the codebase.
api
- API related changesauth
- Authentication/authorizationcore
- Core functionalitydb
- Database relateddeps
- Dependenciesui
- User interfaceconfig
- Configurationbuild
- Build systemtest
- Testingdocs
- Documentationci
- Continuous integration
β¨ feat(auth): implement OAuth2 login
π fix(api): handle empty response correctly
π docs(readme): add troubleshooting section
β‘ perf(db): optimize query performance
Breaking changes MUST be indicated by:
!
after type/scope:π₯ feat(api)!: change response format
- BREAKING CHANGE in footer:
β¨ feat: allow provided config object to extend other configs
BREAKING CHANGE: `extends` key in config file is now used for extending other config files
Always ensure that tests, linting, and builds pass before committing:
- Run all tests and verify they pass
- Run linting tools and fix any issues
- Ensure the project builds successfully
- Never commit broken code
- Emoji is mandatory: Every commit must start with an appropriate emoji
- Type is mandatory: Every commit must have a type after the emoji
- Description is mandatory: Must be in present tense, not capitalized, no period at the end
- Line length:
- Subject line: max 72 characters
- Body: wrap at 72 characters
- Separate subject from body: With a blank line
- Start with an emoji
- Follow with type and optional scope
- Use the imperative, present tense: "change" not "changed" nor "changes"
- Don't capitalize the first letter of description
- No dot (.) at the end
- Use when the commit requires explanation
- Explain the motivation for the change
- Wrap at 72 characters
- Can use bullet points with
-
or*
- Reference issues:
Closes #123
,Fixes #456
- Note breaking changes:
BREAKING CHANGE: description
- Co-authors:
Co-authored-by: Name <email>
β¨ feat: add user profile page
π fix: prevent race condition in data fetching
π docs: correct spelling in README
β¨ feat(auth): add password reset functionality
π fix(ui): correct button alignment on mobile
β‘ perf(api): implement response caching
π fix: prevent service timeout during upload
The previous timeout of 30 seconds was insufficient for large
file uploads. This commit increases the timeout to 5 minutes
and adds a progress indicator.
Closes #89
π₯ feat(api)!: change authentication to use JWT
BREAKING CHANGE: API now uses JWT tokens instead of session cookies.
All API clients must be updated to send Authorization header.
Migration guide:
- Update client to store JWT token
- Send token in Authorization header: `Bearer <token>`
- Remove cookie handling code
π fix: correct minor typos in code
See the issue for details on the typos fixed.
Reviewed-by: Alice <[email protected]>
Refs #133
Fix bug // Missing emoji and type format, capitalized
feat: Add new feature // Missing emoji
β¨ feat Added new feature. // Missing colon, capitalized, period
update code // Missing emoji, vague, no type
β¨ feat: add login, fix navigation, update styles // Multiple changes
- Make atomic changes - One logical change per commit
- Choose correct emoji and type - Select the most appropriate combination
- Add scope if helpful - When it adds clarity
- Write clear description - Explain what, not how
- Add body if needed - For complex changes
- Reference issues - Link related issues
- Mark breaking changes - When applicable
Interactive commit message helper:
npm install -g commitizen
npm install -g cz-conventional-changelog
echo '{ "path": "cz-conventional-changelog" }' > ~/.czrc
For emoji support:
npm install -g cz-emoji
echo '{ "path": "cz-emoji" }' > ~/.czrc
Usage:
git cz
Enforce commit conventions with emoji support:
// commitlint.config.js
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']],
'header-pattern': [2, 'always', /^[\u{1F300}-\u{1F9FF}][\s\S]*$/u]
}
};
npm install --save-dev husky
npx husky add .husky/commit-msg 'npx --no -- commitlint --edit "$1"'
Configure semantic-release to parse emoji commits:
{
"plugins": [
["@semantic-release/commit-analyzer", {
"preset": "conventionalcommits",
"parserOpts": {
"headerPattern": "^(\\p{Emoji}+)\\s+(\\w+)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\!?:\\s+(.+)$/u",
"headerCorrespondence": ["emoji", "type", "scope", "subject"]
}
}],
"@semantic-release/release-notes-generator",
"@semantic-release/github"
]
}
Create .gitmessage
:
# <emoji> <type>[optional scope]: <description>
#
# [optional body]
#
# [optional footer(s)]
# Emoji Guide:
# β¨ feat: New feature
# π fix: Bug fix
# π docs: Documentation
# π¨ style: Formatting
# β»οΈ refactor: Code refactoring
# β‘ perf: Performance
# β
test: Testing
# ποΈ build: Build system
# π· ci: CI/CD
# π§Ή chore: Maintenance
# βͺ revert: Revert changes
Configure:
git config --global commit.template ~/.gitmessage
- Conventional Commits - Official specification
- Gitmoji - Emoji for Git commits
- Angular Convention - Convention that inspired Conventional Commits
- Semantic Versioning - How commits relate to version numbers
- Commitizen - CLI helper for writing commits
- Commitlint - Lint commit messages