Interview Q&A / Git & GitHub

BeginnerQuick answer1 min readUpdated 3 Oct 2026

What makes a good Git commit message?

SHORT ANSWER

A short imperative summary line of about 50 characters, a blank line, then an optional body explaining why the change was made. Describe the reason, not just what the diff already shows.

Explain it simply

A commit message is a note to a colleague who opens the log six months later, perhaps you.

'fixed stuff' tells them nothing. 'Fix rounding error in GST total' tells them what, and the body can say why: the old code truncated paise. Convention: subject in the imperative mood ('Add', 'Fix', not 'Added'), no full stop, around 50 characters, then a blank line, then a body wrapped near 72 characters. One logical change per commit makes the message easy to write.

Example

text
Fix rounding error in GST total

The old code truncated paise, so invoices were off by up to
one rupee on large orders. Round to two decimals instead.

Closes #87

What to say in the interview

"I write a short imperative subject, a blank line, and a body that explains why the change was needed. Each commit is one logical change, so the message stays honest and the history is searchable."

#git#commit-message#best-practice

Related questions

Practise more Git & GitHub questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Git & GitHub quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.