19 July 20252 min read

Today I learned how to write structure, easy-to-communicate commit messages in Git.

A clear, consistent commit message format helps:

  1. Quickly understand project history
  2. Filter and find specific changes (e.g. documentation vs code)
  3. Generate changelogs automatically (see below for details)

Use the Conventional Commits standard:

Terminal window
<type>(<scope>): <description>
[optional body]
[optional footer]
  • Header/Subject (type + scope + description) is required
    • Keep the subject line under 72 characters
  • Body and footer are optional

Type Description
feat New feature
fix Bug fix
docs Documentation changes
style Formatting, whitespace, etc. (no code change)
refactor Code refactor (no bug fix or feature)
perf Performance improvement
test Adding or updating tests
chore Routine tasks (build, dependencies, etc.)

  • Use imperative, present tense: “Fix bug” not “Fixed bug”
  • Capitalize the subject line
  • No period at the end of the subject

Example commit messages:

Terminal window
feat(auth): add login with Google OAuth
fix(api): handle token refresh errors
docs(readme): update setup instructions

Tool What It Does When It’s Used
commitizen Interactive CLI that guides you through writing a commit message Before writing commits
commitlint Lints commit messages to ensure they meet the standard and enforce consistency 1 After writing commits
conventional-changelog Automatically generates changelogs from commit history After merging/releasing

Example workflow:

  1. Write commits using the Conventional Commits format.

  2. Run npx conventional-changelog -i CHANGELOG.md -s to update your changelog.

    This command scans your commit history for Conventional Commits, generates a changelog, writes it to CHANGELOG.md (-i CHANGELOG.md), and updates the file in place (-s). The default preset is Angular, but you can omit -p angular for most projects.

    💡 To see all available command line parameters, run: conventional-changelog --help

  3. Optionally, use standard-version or release-it to bump versions and update changelogs automatically.

  1. You can add a Git hook (commit-msg) to validate your commit messages: npx commitlint --edit $1

𖥸
Email Me
Thanks for reading! If you found this page useful, considerbuying me a coffee
No CopyrightCC0 1.0