DEV Community

Thiago Marinho
Thiago Marinho

Posted on

1 1 1

Commit Message Patterns: Write Better Git History

Type: What kind of change (see below).
Scope (optional): What’s affected (e.g., auth, ui, docs).
Description: Short, present-tense summary (50-72 chars).
Body (optional): More details, why it’s done.
Footer (optional): Metadata like "Fixes #123" or "BREAKING CHANGE"

Image description

Common Types of Commit Messages

Here’s a quick reference table for the most frequently used commit types in Conventional Commits:

Type Use Case Example
feat New feature feat(ui): add dark mode toggle
fix Bug fix fix(auth): resolve token expiry
docs Documentation updates docs(readme): update install steps
style Formatting, no logic change style(css): adjust padding
refactor Code cleanup, no behavior change refactor(api): simplify fetch
test Add or update tests test(unit): cover login edge cases
chore Maintenance (deps, tools) chore(deps): update lodash
perf Performance improvement perf(db): optimize query
ci CI/CD changes ci(pipeline): add lint step
build Build system changes build(webpack): minify output
revert Revert a previous commit revert: undo feat(ui)

How to Use This Table

  • Type: Start your commit with one of these keywords.
  • Scope (optional): Add in parentheses (e.g., ui, auth) to specify the area of change.
  • Description: Keep it short, present tense, and descriptive.

Cheat Sheet Examples

Simple Feature

feat(api): add user profile endpoint
Enter fullscreen mode Exit fullscreen mode

Fix with Details

fix(cart): prevent duplicate items
- Added check for existing item ID
- Fixes #45
Enter fullscreen mode Exit fullscreen mode

Breaking Change

feat(auth): switch to JWT tokens
- Replaced session cookies with JWT
BREAKING CHANGE: Old tokens invalid
Enter fullscreen mode Exit fullscreen mode

Chore

chore(deps): bump react to 18.3.0
Enter fullscreen mode Exit fullscreen mode

Refactor

refactor(utils): extract logger to module
Enter fullscreen mode Exit fullscreen mode
  • Improves reusability across files

Tips

  • Scope: Keep it lowercase, short (e.g., ui, server).
  • Breaking Changes: Flag with ! after type (e.g., feat(ui)!: redo layout) or note in footer.
  • Tools: Use with semantic versioning or changelog generators (e.g., standard-version).

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay