What are Git hooks and where do they live?
BeginnerConceptHooks, submodules, LFS and signing
Answer
Scripts that Git runs at defined points, stored in .git/hooks (not versioned). Client hooks include pre-commit, commit-msg, pre-push; server hooks include pre-receive and update. A hook that exits non-zero aborts the operation.
cat > .git/hooks/pre-commit <<'H'
#!/bin/sh
npm run lint --silent || exit 1
H
chmod +x .git/hooks/pre-commit
More on Hooks, submodules, LFS and signing
How do you share hooks with a team, given `.git/hooks` is not committed?IntermediateWhat does the `commit-msg` hook receive and what is it good for?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