Writing clear, structured commit messages makes collaboration smoother, code reviews easier, and project history understandable. Here's a simple guide I follow:
Commit Message Structure
<type>(<scope>): <short description>
- type → the kind of change
- scope → optional, the affected module
- description → concise summary (imperative mood) ### Common Types
-
feat:
→ new features -
fix:
→ bug fixes -
chore:
→ maintenance, build updates, configs -
docs:
→ documentation -
refactor:
→ code improvements without changing behavior -
style:
→ formatting, linting, whitespace -
test:
→ adding/updating tests Example:
feat(auth): add login with Google
fix(api): handle null pointer on user fetch
chore: update dependencies
Best Practices
-
Imperative tone – describe what the commit does:
✅
fix(ui): remove extra padding on button
❌fixed padding issue
- Keep subject short – ≤ 50 characters
- Use body for details – explain why, not just what:
feat(auth): add password reset
- Added endpoint /auth/reset-password
- Updated email templates
- Closes #123
✅ Clean commits = better teamwork & smoother code history! 🛠️💡
Top comments (2)
It is very useful, thanks!
You are welcome :)