A standardized way to write clear, meaningful Git commit messages.
Improves collaboration, simplifies project management, and automates changelog generation.
- Better Communication: Write commit messages that everyone (and machines!) can understand.
- Project Clarity: Track changes by type (e.g., features, fixes, docs) and scope (e.g., component, module).
- Automated Workflows: Enable semantic versioning and auto-generated changelogs.
- Team Alignment: Reduce ambiguity in collaborative environments.
- Stage Changes
git add <files>orgit add .(to stage all changes). - Commit with Message
git commit -m "type(scope): description"
Example:
git commit -m "feat(auth): add password reset endpoint" - Push to Remote
git push origin <branch-name>
type(scope): description # Required
<BLANK LINE>
body # Optional
<BLANK LINE>
footer # Optional (e.g., for breaking changes)
- Type: Purpose of the change (e.g.,
feat,fix,docs). - Scope (Optional): Module/component affected (e.g.,
api,button). - Description: Concise summary in imperative tense ("add" vs "added").
- Body/Footer: For detailed explanations, breaking changes, or issue links.
| Type | Use Case | Example |
|---|---|---|
feat |
New feature | feat(profile): add dark mode |
fix |
Bug resolution | fix(login): handle 404 errors |
docs |
Documentation updates | docs: update API guidelines |
style |
Code formatting/readability | style: format CSS indentation |
refactor |
Code restructuring (no new features/fixes) | refactor: simplify auth logic |
perf |
Performance improvements | perf(db): optimize queries |
test |
Test-related changes | test: add login unit tests |
build |
Build system/config changes | build: update webpack config |
ci |
CI/CD pipeline updates | ci: fix GitHub Actions workflow |
revert |
Undo a previous commit | revert: remove experimental API |
design |
UI/UX changes | design(button): update hover effect |
eod |
Backup work-in-progress code at EOD | eod: WIP user dashboard layout |
- Use Imperative Mood
Write "fix" instead of "fixed" or "fixes". - Keep It Short
Limit the subject line to 50 characters. Use the body for details. - Reference Issues
Include Jira tickets or GitHub issues:
git commit -m "feat: user profile [PROJ-42]" - Breaking Changes
Add!after the type/scope and explain in the footer:
feat(api)!: remove deprecated endpoints - Multi-Line Commits
Usegit commitwithout-mto open an editor for longer messages.
Use the eod type to back up work-in-progress code to the remote branch:
git commit -m "eod: WIP user dashboard layout [PROJ-15]"
git push origin <branch-name>Include the ticket ID + title directly:
git commit -m "[PROJ-123] fix(payment): resolve currency rounding error"- Automate Enforcement
Use tools like Commitlint and Husky to validate messages.
commit-style-cheatsheet
Dev: Hussain Hanif
Feel free to contribute or suggest improvements! π