- Multiple global git hooks
- Multiple per-repo git hooks
- Existing hooks keep working
- All hooks run in parallel
- No configuration files
Configure Git hooks once, use them everywhere. No more copy-pasting hooks between repos like it's 2005.
NOTE: This repo requires git version 2.54 (or later). If you're using an older version of git then checkout the older version of this repository using: git checkout pre-git-2-54.
When you trigger any Git hook (like pre-commit), Git Multi-Hook runs all of the following hooks at the same time, in parallel:
- Global hooks → all scripts in
./hooks/pre-commit.d/* - Repo hooks → all scripts in
$YOUR_REPO/.git/hooks/pre-commit.d/*
Any existing hook will also be run by git itself:
- Default hook →
$YOUR_REPO/.git/hooks/pre-commit
Within each category, scripts are started in alphabetical order (use 01-, 02- prefixes for ordering).
All the hooks run at the same time (up to the number of CPUs in the computer). Results are reported in launch order, one after another until a hook reports failure or all succeed.
Existing hooks work with no changes.
Run the setup script and you're good to go:
./setupWant to add a new global hook? Easy peasy:
# Create the directory for the type of hook you want (if it doesn't exist already)
mkdir -p hooks/pre-commit.d
# Drop your script in there
cp your-awesome-script.sh hooks/pre-commit.d/
# Make it executable
chmod +x hooks/pre-commit.d/your-awesome-script.sh
# Re-run setup to link to your gitconfig
./setupAdd repo-specific git hooks similarly by copying to $YOUR-REPO/.git/hooks/pre-commit.d/ instead.
ALL standard Git hooks supported:
pre-commit→ Last chance to check before committingprepare-commit-msg→ Auto-generate or modify commit messagescommit-msg→ Validate commit message format (hello, conventional commits!)post-commit→ Celebrate after a successful commit 🎉pre-rebase→ Safety checks before rewriting historypost-checkout→ Run after switching branchespost-merge→ Clean up or notify after mergespre-push→ Final checks before code leaves your machinepost-rewrite→ Triggered bygit commit --amendand rebasespre-merge-commit→ Validate before creating a merge commit
applypatch-msg→ Edit commit messages from patchespre-applypatch→ Validate patches before applyingpost-applypatch→ Run after successfully applying patchessendemail-validate→ Check patches before emailing
pre-receive→ Gatekeeper for incoming pushesupdate→ Validate each ref being updatedpost-receive→ Trigger CI/CD or notificationspost-update→ Run after all refs are updatedpush-to-checkout→ Handle non-bare repository pushes
Something not working? Turn on verbose mode to see what's happening:
VERBOSE=2 git commit -m "debugging time!"Shows you which hooks are running in what order.
git --no-verify commit -m "living dangerously"This repository includes several hooks already pre-configured.
end-with-blank-line: Ensures staged source and config files end with a trailing newline.find-do-not-commit: Blocks commits when staged files containDO NOT COMMIT(setIGNORE_DO_NOT_COMMIT=1to warn instead).lint-code: Runs$REPO/scripts/linton staged files if it exists.lint-nodejs: Runsnpm|yarn|pnpm run lintif$REPO/package.jsonhas alintscript.lint-shellcheck: Runsshellcheckon staged shell scripts (setIGNORE_SHELLCHECK=1to skip).lint-swift: Runsswiftlinton staged.swiftfiles when.swiftlint.ymlis present (setIGNORE_SWIFT_LINT=1to skip).prevent-commit-secrets: Runsripsecretsagainst staged files (setIGNORE_SECRETS=1to skip).validate: Runs$REPO/scripts/validateon staged files if it exists.
Found a bug? Have an awesome hook to share? PRs are welcome!
Apache License, Version 2.0
git-multi-hook Copyright © 2026 Patrick Wyatt
See LICENSE.md for details.
Thanks to Simon Epskamp. This repo is based on his stackoverflow post.