🔀 Git: Fix Hooks Never Firing Because of core.hooksPath
Setting core.hooksPath — commonly done by a tool like Husky to centralize hooks in a version-controlled folder — tells Git to look for every hook exclusively in that configured directory instead of the repository’s own .git/hooks folder, completely, with no fallback. A hook script added directly to .git/hooks afterward (by a different tool, or by a developer following an outdated setup guide) will sit there correctly named and correctly executable and simply never run, because Git isn’t looking in that folder at all anymore, and there’s no warning printed anywhere that a hook exists in a location Git has stopped checking.
🔎 The Problem
$ git config core.hooksPath
.husky
$ ls -la .git/hooks/pre-commit
-rwxr-xr-x 1 dev staff 412 Nov 20 10:14 .git/hooks/pre-commit
<- correctly executable, correctly named, correctly written
$ git commit -m "test"
<- pre-commit never runs, no error, no mention that a hook exists
in a path Git has stopped looking at since core.hooksPath
redirected it entirely to .husky/
✅ Fix: Check core.hooksPath First, Before Debugging the Hook Itself
- Run
git config core.hooksPathas the very first troubleshooting step any time a hook doesn’t seem to fire — if it returns a value, every hook script sitting in.git/hooksis being ignored entirely, and the fix is either moving the script to the configured path or unsettingcore.hooksPath, not debugging the script’s contents. - Keep hook scripts in exactly one location per repository and document which one is authoritative in the project’s README or contributing guide — a repo with scripts scattered across both
.git/hooksand acore.hooksPath-configured folder is a recurring source of “it works on my machine” confusion as developers add scripts to whichever location they happened to look in first. - If removing
core.hooksPathentirely isn’t an option (a team tool depends on it), move any stray.git/hooksscripts into the configured hooks directory and make sure they’re committed to version control there, since.git/hooksitself is never tracked by Git and any script living only there is invisible to every other clone of the repo anyway.
🚨 Why This Is Dangerous
- A pre-commit or pre-push check that silently never runs gives every commit the false confidence of having passed validation it never actually received, which is far more dangerous than an obviously broken hook that fails loudly — nobody investigates a safety check that appears to be passing.
Git doesn’t merge two hook directories and doesn’t warn you when it’s ignoring one — core.hooksPath picks exactly one place to look, and a script anywhere else is invisible to it.





