🧠 Mastering Git: Writing Meaningful Commit Messages

When working on software projects β€” especially collaborative ones β€” using Git effectively is crucial. While many developers are comfortable with basic Git commands, one often overlooked skill is writing clear, meaningful commit messages.

Lutfi Ikbal Majid
Lutfi Ikbal Majid
3 min readΒ·Jun 18, 2025
🧠 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:).


Why Good Commit Messages Matter

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!


The Anatomy of a Good Commit Message

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

βœ… Basic Format

<type>: <subject>

<body> (optional)

πŸ”§ Type (required)

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:

Type Description
feat A new feature
fix A bug fix
docs Documentation only changes
style Code style changes (no logic)
refactor Code refactoring (no features/bugs)
perf Performance improvements
test Adding tests or fixing them
chore Maintenance tasks (e.g., build, deps)
ci CI/CD configuration changes
build Build system or external dependency changes
revert Reverts a previous commit

πŸ“ Subject (required)

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

πŸ’¬ Body (optional)

If needed, explain what and why you did something. Avoid the β€œhow” β€” the code shows that.


✨ Examples of Good Commit Messages

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

πŸ›  Tips for Better Commits

  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.

    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:

    git commit --amend

🧰 Tools That Help

  • 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.

🎯 Summary

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:

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

πŸ“š Further Reading


Recommended from Lutfi

See all writings