The commit message is the cheapest documentation you will ever write, and the one you will read most often. Six months from now, git log is the only record of why the code looks the way it does.
Most commits say what changed. fix bug, update styles, refactor. Those tell you nothing you could not get from the diff, and the diff is unreadable at a glance anyway.
The version that helps is the one that says why, in one sentence, and what would break if it were reverted.
The shape I use now
fix: invoice totals double-counted tax on refunds Refund rows carry tax twice (once on the credit, once on the original). Filter refunds out of the tax sum before totalling. Reverting this brings back the 3% overcharge on refunded orders. Three lines: what, why, and the consequence of undoing it. It takes twenty seconds and it answers the question you will actually ask later, which is not "what changed" but "was this deliberate".
Prefixes that earn their place
fix: something was wrong. feat: something new. refactor: behaviour unchanged. chore: housekeeping. That is enough. Longer taxonomies get argued about more than they get used.
The rule about "why"
If the why is in a ticket, put the ticket id in the message. If it is not written anywhere, write it in the message, because the ticket will be closed and the context will be gone.
The test
Before committing, ask: if I read only this message in a year, would I know whether it is safe to undo? If not, the message is not finished.
The best commit log I have read belonged to a project whose author had left. Every message explained a decision. Reading it was like having the author beside you, saying "I tried the obvious thing and it broke here". That is what a good log does, and it costs almost nothing to leave behind.


