Skip to content
BENIBIX Learn

Commit Message

Development🔀 Version ControlGit Basics

Also known as Git Commit Message, Commit Title, Commit Log Message

The note saved with a commit. It says what changed and why.

Think of it like

Think of it like a note you stick on a box before you store it. It says what is inside and why.

Example

Lucy writes the title Fix the price on the order page. In the body she adds that coupons made tax show twice.

Why it matters

Months later, the message is often the only clue to why a line was changed.

Definition

A commit message is the note saved with each commit. It says what changed and why. Git's own advice is a short first line of no more than 50 characters, then a blank line. After that comes a longer body if one is needed. The first line is the title that tools show in lists.

Example code

console
$ git commit -m "Fix the price on the order page" -m "Coupons made the tax show up twice."
[main 7b8c9d0] Fix the price on the order page
 1 file changed, 2 insertions(+), 1 deletion(-)
The first -m is the title. The second -m is the body.
The message is the title line, a blank line, then the body.

Common mistake

Writing fix or stuff. A message that says nothing is no help when you search the history.

Key takeaways

  1. 1
    Short title. No more than 50 characters.
  2. 2
    Say why. The diff shows what. Say why.
  3. 3
    Blank line. Leave one between title and body.

Learn it properly