What is a good commit message and commit size?
Options
- 'fix' as the message, and one huge commit per week
- A short imperative summary, in a small focused commit (Correct option)
- The full source code of the changed file as text
- Only emojis as the message, with no further text
Answer
A short, imperative summary of WHAT and WHY ("Fix null email in signup"), in a small commit that does one logical change
Why
Small, focused commits make history readable, reviews easier, git bisect possible and reverts safe.
Subject line: imperative mood, about 50 characters ("Add retry to payment client"). Optional body explaining why. Reference the ticket (PROJ-123).
Avoid: "fix", "stuff", "WIP", and mixing refactoring with feature changes in one commit.
Remember
One logical change per commit; explain the why.