Commit Messages

Writing Commit Messages That Explain Why

The diff shows what changed; the message records what it cannot show: why. Git 1,932 's conventions, which tools assume, are short:

Commit BookNest's application code with a body that records a design decision, then the tests and README:

Committing with a subject and a bodyShell
git add app.js server.js db public
git commit -F - <<'EOF'
Add the Express API, PostgreSQL layer and front end
BookNest serves its catalog from PostgreSQL rather than a JSON file
so that stock levels can change while the API runs. /health never
touches the database and /ready does, so an orchestrator can restart
a hung process without restarting it for a slow database.
EOF
git add test docker-compose.yml README.md
git commit -qm "Add integration tests, local PostgreSQL and a README"
Output
[main 15a2012] Add the Express API, PostgreSQL layer and front end
 6 files changed, 260 insertions(+)
 create mode 100644 app.js
...
 create mode 100644 server.js

-F - reads the message from standard input; interactively, plain git commit opens core.editor. Messages like "fix" or "wip" cost nothing today and hours in a year, when git log and git blame are all that remain of the reasoning. Conventional Commits adds Conventional Commits prefixes (feat:, fix:) for release tools.