Why are commit messages written in the imperative mood?
Git's own messages, like 'Merge branch' or 'Revert commit', are imperative, and the convention completes the sentence 'If applied, this commit will...'. It keeps the log consistent and short.
Explain it simply
A useful test: finish the sentence 'If applied, this commit will ______'. 'Fix login redirect' fits; 'Fixed login redirect' and 'Fixes login redirect' do not.
The reasoning is that a commit is an instruction applied to the code, similar to a recipe step ('Add salt'). It matches what Git generates itself and what git revert writes. It is a style rule, not a technical one, and teams may choose otherwise, but consistency matters more than which rule you pick.
Example
Good: Add dark mode toggle
Bad: Added dark mode toggle
Bad: Adds dark mode toggle
Test: If applied, this commit will add dark mode toggleWhat to say in the interview
"The convention is the imperative, such as Add or Fix, so the subject completes the sentence 'If applied, this commit will...'. It matches messages Git generates itself, and what matters most is that the team stays consistent."