Git is warning that your pre-commit hook file exists but lacks executable permissions. The hook is being skipped, so any pre-commit checks won't run. Fix it by making the file executable with chmod +x.
This warning appears when Git detects a pre-commit hook file in your hooks directory, but the file doesn't have the executable permission bit set. Since Git 2.15/2.16, Git explicitly warns you about this situation rather than silently ignoring the hook. When you commit changes, Git looks for hook scripts in the `.git/hooks/` directory (or the path specified by `core.hooksPath`). For a hook to run, it must be an executable file. If the file exists but isn't executable, Git will display this hint message and proceed with the commit without running the hook. This commonly happens when hooks are created on Windows (which doesn't have Unix-style permissions), when hooks are copied between systems, or when using tools like Husky that manage hooks automatically.
Run the chmod command to add the executable bit to your pre-commit hook:
chmod +x .git/hooks/pre-commitIf you have multiple hooks that need to be fixed:
chmod +x .git/hooks/*This is the most common fix and works on Linux and macOS.
Check the current permissions on your hook file:
ls -la .git/hooks/pre-commitYou should see an 'x' in the permissions, like:
-rwxr-xr-x 1 user user 1234 Jan 1 12:00 pre-commitIf the file shows -rw-r--r-- (no x), it's not executable.
On Windows, the file system doesn't support Unix-style permissions. Use Git's built-in option to set the executable bit:
git add --chmod=+x .git/hooks/pre-commitAlternatively, if you're using Git Bash, the chmod command should still work:
chmod +x .git/hooks/pre-commitVerify which hooks directory Git is using:
git config core.hooksPathIf this returns a custom path (like .husky), make sure the hooks in that directory are executable:
chmod +x .husky/pre-commitIf core.hooksPath is not set, Git uses .git/hooks/ by default.
If you're using Husky for Git hooks, add a prepare script that ensures hooks are executable:
{
"scripts": {
"prepare": "husky install && chmod ug+x .husky/*"
}
}Then run:
npm run prepareThis ensures hooks are executable after installation on any Unix-based system.
If chmod doesn't work, your file system might be mounted with the noexec flag. Check mount options:
mount | grep $(df . --output=source | tail -1)If you see noexec in the output, you'll need to remount the partition or work in a directory on a different file system. This is common on:
- Dual-boot systems with NTFS partitions
- Mounted network drives
- Some Docker volume mounts
If you intentionally want hooks to be non-executable (to disable them), you can suppress the warning:
git config advice.ignoredHook falseNote: This only hides the warning. If you actually want the hooks to run, fix the permissions instead.
### Understanding core.hooksPath
Git allows you to specify a custom hooks directory via core.hooksPath. This is commonly used by:
- Husky: Uses .husky/ directory
- pre-commit framework: Can use various paths
- Team-shared hooks: Often stored in a hooks/ directory in the repo
Check your configuration:
git config --list | grep hooks### Committing Executable Permissions
Git tracks the executable bit in the repository. If you need hooks to be executable for your team:
# Stage the permission change
git update-index --chmod=+x hooks/pre-commit
# Or if adding a new file
git add --chmod=+x hooks/pre-commit### core.fileMode Setting
If core.fileMode is false, Git ignores file permission changes. This is often set automatically on Windows. Check with:
git config core.fileMode### WSL and Windows Interoperability
When using WSL (Windows Subsystem for Linux) with repositories on Windows drives, permission handling can be tricky. Best practices:
- Keep repositories on the Linux file system (/home/...) rather than Windows mounts (/mnt/c/...)
- Or configure WSL's /etc/wsl.conf to handle metadata properly
### Hook File Requirements
For a hook to run, it must:
1. Be in the correct directory (.git/hooks/ or core.hooksPath)
2. Have the exact hook name (e.g., pre-commit, not pre-commit.sh)
3. Be executable
4. Have a valid shebang line (e.g., #!/bin/sh or #!/bin/bash)
warning: BOM detected in file, this may cause issues
UTF-8 Byte Order Mark (BOM) detected in file
fatal: Server does not support --shallow-exclude
Server does not support --shallow-exclude
warning: filtering out blobs larger than limit
Git partial clone filtering large blobs warning
fatal: Server does not support --shallow-since
Server does not support --shallow-since in Git
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server