Lesson 2.5.2: Messages
A commit message is read by someone who wasn't there. With a shared format, it makes sense at a glance.
The idea
A commit message is read by someone who wasn't there: you, three months from now, or whoever works with you. It has to say what changes, in a format everyone reads the same way.
The most widely used format is called Conventional Commits:
type(scope): short summary
- detail 1
- detail 2
The structure
| Part | What it is | Example |
|---|---|---|
type | What kind of change it is. Always there | feat |
(scope) | Which part of the project it touches. Optional | (table) |
: summary | What the change does, in one short line | : let the user choose the table's number |
| Body | The details, as bullets, after a blank line. Optional | - the table(n) function writes any table |
The scope isn't the branch: it's the part of the project that changes, like table, game or page.
The types
| Type | When |
|---|---|
feat | Something new: a function, a page |
fix | Fixing a bug |
docs | Documentation only |
style | Formatting: spaces, indentation, commas. The code does the same |
refactor | Reorganising code without changing what it does |
test | Adding or changing tests |
chore | Maintenance: configuration, dependencies |
There are more (perf, build, ci), but these cover almost everything.
The rules
- Short summary: about 50 characters, no full stop.
- Lowercase, saying what it does: "add", not "added" or "adding".
- One commit, one change: if the summary needs "and", it's probably two commits.
Writing a message with a body
-m is for one line. For a message with details, it's better to write it in VS Code. Once:
git config --global core.editor "code --wait"
On macOS, first, in VS Code: Cmd + Shift + P → Shell Command: Install 'code' command in PATH.
From then on, git commit without -m opens the message in VS Code:
git commit
Write it, save and close the tab: the commit happens when you close it.
feat(table): let the user choose the table's number
- the table(n) function writes the table for any number
- table.js calls it with 3, as before
This is how it looks in the history:
git log -1
commit 66c4396a81db05aa5bc2940c0f5b6a6642b44c9b (HEAD -> main)
Author: Ana García <ana@example.com>
Date: Tue Oct 20 18:30:00 2026 +0200
feat(table): let the user choose the table's number
- the table(n) function writes the table for any number
- table.js calls it with 3, as before
From here on, the course's commits follow this format.
Try it
Write the message for each change:
table.jsstopped at 9 and you fix it so it reaches 10.- You rename the variable
itonumberso it reads better. The program does the same. - You add a goodbye to
hello.js.
Show the solution
fix(table): reach 10
refactor(table): rename i to number
feat(greeting): add the goodbye
One message per commit: that's three commits, not one.
Summary
type(scope): summary, and if needed, details as bullets after a blank line.- The type says what kind of change it is:
feat,fix,refactor… - The scope is the part of the project, not the branch.
- Short summary, lowercase, saying what it does. One commit, one change.