Write a Good Commit Message
A commit message is a note to your future self. A good message says what changed and why it changed.
A clear message
The verb Add says what the snapshot does.
$ git commit -m "Add butter to the shopping list"A message with a reason
The second -m adds the reason under the subject.
$ git commit -m "Add pancake recipe" -m "Lists the three ingredients so the recipe is ready to cook."Example
$ git log --onelineKey points
- Write the message in the present tense.
- Start with a verb: Add, Fix, Change, Remove.
- Say what changed, not how you changed it.
- One idea per commit keeps messages short.
- A second -m adds a longer reason below the subject.
- Vague messages age badly. “Fix stuff” helps nobody.
- The log shows messages, so they are the first thing a reader sees.
Here, the log reads like a diary. Each line says what changed. The newest snapshot sits at the top.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
Which message is best?