Commits
Structured messages with types (e.g. Feat, Fix).
Commit Message Structure
[Optional Emoji] <Type>([Optional Scope]): <Subject>
# Examples:
โจ Feat(auth): Add password strength meter
๐ฉน Fix: Resolve infinite loading issue
โป๏ธ Refactor(api): Simplify response handling
Components:
- Emoji: Optional visual indicator (improves scanability)
- Type: Required category identifier (e.g. Feat, Fix)
- Scope: Optional context specifier in parentheses
- Subject: Concise description in present tense (imperative mood)
Supported Types
Emoji | Type | Description | Example |
---|---|---|---|
๐ ๏ธ | Build | Changes to build system, tools or dependencies | ๐ ๏ธ Build(webpack): Upgrade to version 5 |
๐ | CI | CI/CD pipeline changes | ๐ CI(github): Add linting workflow |
๐ | Docs | Documentation only changes | ๐ Docs: Update API reference |
โจ | Feat | New features or enhancements | โจ Feat(user): Add profile customization |
๐ฉน | Fix | Bug fixes | ๐ฉน Fix(auth): Resolve session timeout issue |
โก | Perf | Performance improvements | โก Perf(queries): Optimize database lookups |
โป๏ธ | Refactor | Code changes that neither fix bugs nor add features | โป๏ธ Refactor: Extract reusable components |
๐จ | Style | Code style/formatting changes | ๐จ Style: Format according to style guide |
๐งช | Test | Adding or updating tests | ๐งช Test(api): Add integration tests |
โช | Revert | Revert previous changes | โช Revert: Return to commit abc123 |
๐ก๏ธ | Deps | Manage dependencies (e.g. adding/removing libraries) | ๐ก๏ธ Deps: Remove unused Lodash methods |
๐งน | Cleanup | Organize or remove unused code/files | ๐งน Cleanup: Remove unused CSS classes |
๐ฆ | Release | Prepare for a release (e.g. version bump, changelog updates) | ๐ฆ Release: Prepare for v1.0.0 |
๐ | Security | Security-related changes | ๐ Security(auth): Implement rate limiting |
๐ | I18n | Internationalization/localization | ๐ I18n: Add German translations |
โก๏ธ | Migrate | Major migrations or transitions | โก๏ธ Migrate: Convert to TypeScript |
๐ | SEO | Search engine optimization | ๐ SEO: Improve meta tags |
๐ง | AI | AI/ML model or algorithm changes | ๐ง AI: Update recommendation algorithm |
๐ | Data | Data structure or content changes | ๐ Data: Update seed data |
๐ง | Config | Configuration changes | ๐ง Config: Update environment variables |
๐ฏ | UX | User experience improvements | ๐ฏ UX: Streamline checkout process |
๐๏ธ | Struct | Project structure changes | ๐๏ธ Struct: Reorganize component hierarchy |
๐ | Auth | Authentication/authorization | ๐ Auth: Add OAuth integration |
๐ | Track | Analytics or tracking | ๐ Track: Add conversion events |
๐ | API | API-related changes | ๐ API: Add pagination to endpoints |
๐ | Git | Git structure and workflow changes | ๐ Git(hooks): Update pre-commit validation |
Scopes (Optional but Recommended)
Scopes provide additional context about what part of the codebase is affected. Common scopes include:
- Component names:
header
,footer
,nav
- Feature areas:
auth
,checkout
,search
- Technical domains:
api
,db
,ui
,ux
- File types:
css
,js
,tests
Best Practices
- Use the imperative mood for the subject (e.g. "Add feature" not "Added feature")
- Keep subjects concise (under 72 characters)
- Be specific about what changes were made
- No period at the end of the subject line
- Use consistent emoji when applicable
Extended Commit Format (Optional)
For complex changes, you can add a body after the subject:
โจ Feat(auth): Add password strength meter
Implement zxcvbn library to provide real-time feedback on password strength.
- Displays color-coded strength indicator
- Shows improvement suggestions
- Prevents submission of weak passwords
Issue: #123
Example Workflow
Scenario: Adding a new feature and fixing related bugs
# Create a feature branch
git checkout -b feat/user-profiles
# Make changes to relevant files
git add src/components/UserProfile.js
git commit -m "โจ Feat(profile): Add user profile editor"
# Fix a bug discovered during implementation
git add src/utils/validation.js
git commit -m "๐ฉน Fix(validation): Resolve email format validation"
# Update documentation
git add README.md docs/api.md
git commit -m "๐ Docs(profile): Document profile endpoints"
# Push changes
git push origin feat/user-profiles
Automated Tools
Consider these tools to enforce ZFGM format:
- commitlint: Validate commit messages against rules
- commitizen: Interactive commit message builder
- husky: Git hooks to validate before commit
- gitmoji-cli: Streamline emoji usage
Advanced Tips
- Co-authored commits: Add
Co-authored-by: Name <email>
at the end of the commit message body - Breaking changes: Mark with
BREAKING CHANGE:
in the commit body - Issue references: Include issue IDs in the commit body or footer
Last updated on