Skip to main content

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

TypeWhen
featNew feature or behavior
fixBug fix
refactorCode change that doesn't add feature or fix bug
docsDocumentation only
styleFormatting, no logic change
testTests
choreTooling, 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

  1. Subject line ≤ 50 chars. If it's longer, the commit does too many things.
  2. Imperative mood. "Add feature" not "Added feature".
  3. Scope is the module or feature, not the file. feat(user-auth) not feat(userService.ts).
  4. One concern per commit. Don't mix a bug fix and a refactor in one commit — they're impossible to revert independently.
  5. The body answers "why", not "what". The diff already shows what changed.