Best Practices
Commit message conventions
Use a consistent commit message structure to improve log readability, release notes quality, and incident-time traceability.
- Individuals or teams who want more predictable Git habits
- Maintainers setting collaboration expectations
- At least one real collaboration loop
- Basic command familiarity without a stable routine yet
- Treating guidance as absolute law without context
- Memorizing process without understanding team boundaries
Citations & Further Reading
- Git commit [Blog]
- Git commit [Official]
- www.conventionalcommits.org — V1.0.0 [Blog]
What you will learn
- Apply the Conventional Commits
<type>(<scope>): <summary>structure, including what belongs in the body - Understand why good commit messages make
git bisect,git log, and CHANGELOG generation actually usable - Spot common commit-message mistakes and know how to correct them during code review
Commit messages are long-term operational metadata, not just local notes.
Start with a problem
After a production incident you tried to trace which commit introduced the bug, but the history was a wall of "fix bug" and "update". git bisect landed on a commit you couldn't interpret, so the root cause took far longer to pin down than it should have.
A practical structure
<type>(<scope>): <summary>
In body text, include:
- why this changed
- what risk or follow-up remains
Example
fix(auth): reject expired refresh token
Align backend token validation with new TTL rule.
Risk: may increase login retries for stale clients.
Team-level rules
- start summaries with an action verb
- explain motivation, not only file edits
- mark breaking changes explicitly
PR context may be collapsed or lost over time. Commit history remains the durable searchable index.
Common misconceptions
- "The message is just for me." The opposite is true. You and your teammates rely on
git logandgit bisectmonths later; vague messages double the cost of every future trace. - "One commit, several unrelated changes." Mixing a login fix with a typo fix means
git revert/git bisectcan't isolate one concern, skewing bisection results. - "Amend a commit that's already pushed." Rewriting shared history makes collaborators'
pullconflict. Use--amendonly for local, unpushed commits; for pushed ones, add a new corrective commit. - "Summary like
fix: bug." No scope, no reason. The conventional formfix(auth): reject expired refresh tokentells readers the blast radius at a glance.
git commit --amend creates a new commit object and replaces HEAD. Once pushed, amending forks everyone else's history and forces a coordinated force-push.
A real incident trace
# Production login failure — find the offending commit
$ git log --oneline -10
a1b2c3d update # no clue what changed
e4f5g6h fix bug # equally uninformative
$ git bisect start <bad> <good>
# bisection stops at "update", but the message hides a broken token check
Had it been fix(auth): reject expired refresh token, the trace would have hit immediately and saved a long investigation.
Good follow-up reads
Try it yourself
- Rewrite the last five commits of a project into Conventional Commits format (
type(scope): summary+ body with reason), then compare the readability ofgit log --onelinebefore and after. - Deliberately split a "login fix" and a "doc typo fix" into two commits, then run
git bisectto feel why single-concern commits matter. - During review, take a
fix: bug-style message and rewrite it using the template, explaining why scope and reason are both required.
Further reading
Keep going on the same topic: