What does the `commit-msg` hook receive and what is it good for?
IntermediateConceptHooks, submodules, LFS and signing
Answer
Git passes the path to a file holding the message as $1. The hook can validate Conventional Commit format, require a ticket ID, or append a trailer, then exit non-zero to reject.
grep -qE '^(feat|fix|chore|docs|refactor|test)(\(.+\))?!?: .+' "$1" || { echo "bad commit message"; exit 1; }
More on Hooks, submodules, LFS and signing
What are Git hooks and where do they live?BeginnerHow do you share hooks with a team, given `.git/hooks` is not committed?IntermediateWhat do `pre-receive` and `update` hooks do and how do they differ?AdvancedWhat is a Git submodule?BeginnerWhy do submodules confuse people and what are the common pitfalls?IntermediateSubmodules versus subtrees versus a monorepo: how do you choose?Advanced