Subject 50 chars, imperative mood, body wrapped at 72, explain why not what, link to the issue, and sign if the project requires it.
A commit message that survives time
Subject: 50 chars, imperative
"Add retry logic to Stripe webhook" — not "Added" nor "Adding".
Blank line, then body
The body explains why: the motivation, the previous behaviour, the new behaviour, edge cases.
Wrap at 72 chars
Email-era convention that still aids
git logreadability.Reference issues and PRs
"Fixes #42" auto-closes the issue when merged.
Sign when required
git commit -S(GPG) or-s(Developer Certificate of Origin). Do not skip unless the project allows it.