Skip to content

🧠 Mastering Git: Writing Meaningful Commit Messages

In this article, we’ll explore why good commit messages matter and how you can follow best practices, including the popular conventional commit style (e.g., feat:, fix:).


A well-written commit message:

  • Explains why something was changed
  • Helps your team understand the context behind changes
  • Makes it easier to debug, review, or revert code
  • Improves collaboration and code maintainability
  • Can be used to auto-generate changelogs

Think of each commit as a log entry in the history of your project — not just for others, but also for your future self!


A good commit message should be concise, descriptive, and follow a consistent format.

<type>: <subject>
<body> (optional)

The type describes what kind of change this is. These are typically short codes that help categorize the nature of the commit.

Here are some commonly used types:

TypeDescription
featA new feature
fixA bug fix
docsDocumentation only changes
styleCode style changes (no logic)
refactorCode refactoring (no features/bugs)
perfPerformance improvements
testAdding tests or fixing them
choreMaintenance tasks (e.g., build, deps)
ciCI/CD configuration changes
buildBuild system or external dependency changes
revertReverts a previous commit

A brief summary (50 characters or less) of the change.

If needed, explain what and why you did something. Avoid the “how” — the code shows that.


Terminal window
feat: add user profile page
Terminal window
fix: prevent null pointer exception in login flow
Terminal window
docs: update contributing guide with setup instructions
Terminal window
refactor: extract validation logic into separate module
Terminal window
perf: optimize image loading speed by lazy-loading thumbnails
Terminal window
test: add unit tests for cart calculation logic
Terminal window
chore: upgrade dependencies in package.json
Terminal window
revert: revert accidental deletion of core library

  1. Use the imperative mood: Like “Fix bug” instead of “Fixed bug” or “Fixes bug”.
    Example: feat: add password strength meter ✅ vs feat: added password strength meter

  2. Keep it concise: Aim for clarity over verbosity.

  3. Link to issues or PRs: If applicable, reference an issue or pull request.

    Terminal window
    feat(auth): implement email verification #1234
  4. Group related changes: Each commit should do one thing. Avoid large commits with unrelated changes.

  5. Review before committing: Double-check your changes (git diff) and ensure your message reflects them accurately.

  6. Amend when necessary: Don’t be afraid to edit your last commit:

    Terminal window
    git commit --amend

  • Commitizen – Interactive CLI to guide you through creating conventional commits.
  • Husky + Commitlint – Enforce commit conventions via linting rules.
  • VSCode Extensions – Many extensions help format and validate commit messages.

Writing good Git commit messages is a small investment that pays off over time. By adopting a standard like Conventional Commits, you’ll make your repository more readable, searchable, and maintainable.

Start today with:

Terminal window
git commit -m "feat(blog): introduce conventional commit style"