Git - Commit Format
The format I follow. Consistent commits make git log actually useful.
Format
<type>(<scope>): <subject>
<body — optional, explains why not what>
<footer — optional, closes #issue>
Types I use
| Type | When |
|---|---|
feat | New feature or behavior |
fix | Bug fix |
refactor | Code change that doesn't add feature or fix bug |
docs | Documentation only |
style | Formatting, no logic change |
test | Tests |
chore | Tooling, deps, config |
Real examples from my history
feat(cards): implement auto debit limit feature
fix(auth): handle expired token refresh correctly
refactor(dashboard): extract chart logic into custom hook
docs(api): add endpoint documentation for payment flow
chore: upgrade dependencies to latest versions
My rules
- Subject line ≤ 50 chars. If it's longer, the commit does too many things.
- Imperative mood. "Add feature" not "Added feature".
- Scope is the module or feature, not the file.
feat(user-auth)notfeat(userService.ts). - One concern per commit. Don't mix a bug fix and a refactor in one commit — they're impossible to revert independently.
- The body answers "why", not "what". The diff already shows what changed.