Hooks in .git/hooks help only the person who wrote them. To share them, commit them to an ordinary directory and point core.hooksPath at it. Git 2.54 1,932 added a second way, hooks defined in configuration, so one repository can run several hooks for the same event:
mkdir .githooks && mv .git/hooks/pre-commit .git/hooks/commit-msg .githooks/
git config set core.hooksPath .githooks
git add .githooks && git commit -qm "Share the pre-commit and commit-msg hooks"
git ls-files --stage .githooks
git config set hook.whitespace.event pre-commit
git config set hook.whitespace.command "git diff --cached --check"
git hook list pre-commit100755 091267610346af074751dfd9a12261497fc2bc1d 0 .githooks/commit-msg 100755 1228aba781bc009eaaf09489cd01b4133b76ccb3 0 .githooks/pre-commit whitespace hook from hookdir
The commit passed through both hooks, now read from .githooks/; mode 100755 shows that Git records the executable bit. git hook list shows both sources Git now consults for pre-commit: the configured whitespace hook, which rejects trailing spaces and leftover conflict markers, and the script. Configured hooks can live in your global configuration and apply to every repository, and Git 2.55 can run them in parallel (hook.<name>.parallel). One step stays manual: configuration is not cloned, so each teammate must run the core.hooksPath line after cloning, and whoever forgets never sees the hooks.