Small porcelain over the .git/hooks dir.
Thin porcelain over the .git/hooks directory: lists, runs, and otherwise pokes the repo's hook scripts. Useful when you want to invoke a hook manually instead of waiting for git to fire it.
Hooks are just executable files in .git/hooks/ (or wherever core.hooksPath points). Git runs them at well-defined moments; git hook run is the manual trigger.
git hook run [--ignore-missing] [--to-stdin=<path>] <hook-name> [-- <hook-args>]
# Hooks live in:
.git/hooks/<name> # default location
$(git config core.hooksPath) # override (team-shared hooks dir)
# Common hooks (chmod +x to enable):
pre-commit, prepare-commit-msg, commit-msg, post-commit
pre-push, pre-rebase, post-checkout, post-merge
pre-receive, update, post-receive, post-update (server side)| Flag | What it does |
|---|---|
run <name> | Execute the named hook as if git triggered it |
--ignore-missing | Exit 0 if the hook isn't installed instead of erroring |
--to-stdin=<file> | Pipe file contents to the hook's stdin |
-- <args> | Pass remaining args to the hook |
chmod -x .git/hooks/X | ⚠️ Disabling a hook by removing the +x bit; trivially reversible but easy to forget |
git hook run pre-commitgit hook run pre-commitgit hook run --to-stdin=draft.txt commit-msg draft.txtgit hook run --ignore-missing pre-pushgit config core.hooksPath .githooks.githooks/) and set core.hooksPath; .git/hooks/ isn't versioned.chmod +x your hooks; a non-executable hook is silently ignored.git hook run in CI to dogfood the same checks devs run locally.*.sample and are inactive; rename them to enable.core.hooksPath overrides .git/hooks/ entirely - the old hooks stop firing without warning.Hit each option, then Check answers. Score is recorded; Next is always open.