Commit Message Templates

commitlint 18,754 rejects a bad message after you have written it; a template reminds you of the rules before you start. commit.template names a file whose text Git 1,932 places in the editor for every git commit without -m. Comment lines are stripped when you save, so the reminders never reach the commit:

A shared commit message template, shown by using cat as the editorShell
cat > .gitmessage <<'MSG'
# <type>(<scope>): <subject>     feat fix docs test refactor perf build ci chore
#   lowercase, imperative, no final period, 72 characters at most
# Body: why the change was needed; the diff already shows what changed.
# Footers: Refs: #42    BREAKING CHANGE: <what breaks and how to migrate>
MSG
git config set commit.template .gitmessage
git -c core.editor=cat commit --allow-empty; echo "exit status $?"
git add .gitmessage && git commit -qm "chore: share a commit message template"
Output
→ lint-staged could not find any staged files.
# <type>(<scope>): <subject>     feat fix docs test refactor perf build ci chore
...
# Please enter the commit message for your changes. Lines starting
...
Aborting commit due to empty commit message.
exit status 1
...

Using cat as the editor prints exactly what your editor would open, after the pre-commit hook has already run; with only comments left, Git aborts, which is also how you cancel a real commit. The file is shared, but each clone sets commit.template once, like commit.gpgSign. For guided input, commitizen 17,497 (github.com/commitizen/cz-cli (https://github.com/commitizen/cz-cli 17,497 ), MIT) asks for the type, scope and description in turn.