Il diff dice gia cosa
Un messaggio che dice "Updated user controller" e byte sprecati — git diff mostra gia che il controller utente e stato aggiornato. La parte preziosa di un messaggio di commit e il perche.
Il formato a sette regole
- Separare oggetto dal corpo con riga vuota.
- Limitare l'oggetto a 50 caratteri.
- Iniziare l'oggetto con maiuscola.
- Non terminare l'oggetto con un punto.
- Usare il modo imperativo.
- Andare a capo nel corpo a 72 caratteri.
- Usare il corpo per spiegare cosa e perche, non come.
Un esempio
git commit -m "Reject negative quantities in checkout
Customers were able to submit negative quantities by editing the
DOM, leading to credits being applied to the order total. We add
server-side validation in CheckoutValidator because client-side
checks alone are insufficient against scripted clients."
Conventional Commits
git commit -m "feat(checkout): reject negative quantities"
git commit -m "fix(auth): handle expired refresh tokens"
git commit -m "docs(readme): clarify install steps"
I template lo rendono automatico
cat > ~/.gitmessage 'EOF'
# Subject (50 chars max)
# Why is this change necessary? (wrap at 72 chars)
# How does it address the problem?
# Side effects, follow-ups, links?
EOF
git config --global commit.template ~/.gitmessage
Riferimenti agli issue
git commit -m "Fix avatar upload race condition
See: PROJ-2207
Co-authored-by: Alex Tan "