Skip to content
Programming contents

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

PartWhat it isExample
typeWhat kind of change it is. Always therefeat
(scope)Which part of the project it touches. Optional(table)
: summaryWhat the change does, in one short line: let the user choose the table's number
BodyThe 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

TypeWhen
featSomething new: a function, a page
fixFixing a bug
docsDocumentation only
styleFormatting: spaces, indentation, commas. The code does the same
refactorReorganising code without changing what it does
testAdding or changing tests
choreMaintenance: 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:

Terminal
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:

Terminal
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:

Terminal
git log -1
Terminal
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

Exercise

Write the message for each change:

  1. table.js stopped at 9 and you fix it so it reaches 10.
  2. You rename the variable i to number so it reads better. The program does the same.
  3. 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.