git hook: permission denied / bad interpreter
Quick summary
Your git hook in .git/hooks/ is not running because the file is not executable or the shebang line points to a non-existent interpreter.
Why this happens
The hook script file was created without execute permission (chmod +x) so git cannot run it
The shebang line (e.g., #!/usr/bin/env python3) points to an interpreter not installed or at a different path
The hook filename has a typo or wrong extension — git only recognizes exact names like pre-commit, post-merge
Minimal example
# .git/hooks/pre-commit has no execute bit
git commit -m 'test' # hook silently skippedchmod +x .git/hooks/pre-commit
git commit -m 'test' # hook now runsGit requires hook scripts to have the execute permission bit set; without it, the hook is silently ignored rather than executed.
How to diagnose
Run ls -la .git/hooks/ to check file permissions — hooks need the execute bit set
Run cat .git/hooks/pre-commit to inspect the shebang line and verify the interpreter path exists
Run the hook manually with .git/hooks/pre-commit to see the exact error from the shell
How to fix
Add execute permission with chmod +x .git/hooks/<hook-name> so git can invoke the hook
Fix the shebang to point to the correct interpreter, e.g., #!/usr/bin/env bash or #!/usr/bin/env python3
Rename the hook file to the exact git hook name (pre-commit, pre-push, post-merge, etc.) without extensions
How to prevent
Use a hook management tool like husky or pre-commit that handles permissions and paths automatically
Test hooks locally by running them directly before relying on git to invoke them