← Garden

Writing Git Commit Messages

Published
Aug 20, 2023
Updated
Nov 29, 2026
Reading
2 min read
Tags
#git

Conventional Commits is a small set of rules for commit messages. Each message says what kind of change it is (a feature, a fix, a breaking change), so the history is easy to scan, and tools can generate changelogs and version numbers from it.

Structure

<type>[optional scope]: <description>
[optional body]
[optional footer(s)]

For example:

feat: add dark mode toggle
fix(nav): close menu after selecting a link
chore(prettier): switch tabs to spaces

The usual style for the description is the imperative mood (“add”, not “added”), lowercase, with no full stop. It should finish the sentence “this commit will…”.

Types

The spec only defines feat and fix. The rest come from the widely used Angular convention:

  • feat: a new feature
  • fix: a bug fix
  • docs: documentation only
  • style: formatting that doesn’t change behaviour (whitespace, semicolons)
  • refactor: a code change that neither fixes a bug nor adds a feature, e.g. renaming a function
  • perf: a performance improvement
  • test: adding or updating tests
  • build: the build system or dependencies, e.g. adding a package
  • ci: CI configuration and scripts
  • chore: maintenance that users won’t see, e.g. .gitignore or .prettierrc
  • revert: reverts an earlier commit

The scope is optional and names the part of the codebase that changed: fix(auth):, feat(api):.

Body and footers

Use the body to explain why the change was made when the description alone isn’t enough. Footers come after a blank line, in Token: value form:

fix(api): retry requests after a timeout
The upstream service drops connections under load,
so a single failed request was surfacing as an error.
Refs: #42

Breaking changes

A commit with a BREAKING CHANGE: footer, or a ! after the type/scope, introduces a breaking API change (correlating with MAJOR in Semantic Versioning). A breaking change can be part of a commit of any type.

feat(api)!: rename `getUsers` to `getUsersList`
BREAKING CHANGE: `getUsers` has been removed.

How it maps to versions

Commit Version bump
fix PATCH
feat MINOR
! or BREAKING CHANGE: MAJOR
anything else none

Resources