How to fix hint: The '.git/hooks/pre-commit' hook was ignored because it's not set as executable in Git
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.
Quick fix
Fixes hint: The '.git/hooks/pre-commit' hook was ignored because it's not set as executable
chmod +x .git/hooks/pre-commit- Make the hook file executable
- Verify the file has executable permissions
- For Windows users: Use git add --chmod
- Check if the hooks directory is correct
chmod +x .git/hooks/pre-commithint: The '.git/hooks/pre-commit' hook was ignored because it's not set as executable
What this error means
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.
Typical symptoms
- The hint message appears every time you run git commit
- Pre-commit checks (linting, tests, formatting) don't run before commits
- Commits succeed even when they should fail validation
- The warning appears after cloning a repository or switching branches
- Hook scripts work for some team members but not others
Common causes
- The hook file was created without the executable bit set (common when creating files on Windows)
- The repository was cloned or created on Windows and opened on Linux/macOS
- The hook file was copied manually without preserving permissions
- The file system is mounted with the noexec flag, preventing any executable permissions
- Git's core.fileMode is set to false, causing permission changes to be ignored
- Hook management tools like Husky didn't properly set permissions after installation
How to fix "hint: The '.git/hooks/pre-commit' hook was ignored because it's not set as executable"
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.
Advanced notes
### 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)
Frequently asked questions
- What does "hint: The '.git/hooks/pre-commit' hook was ignored because it's not se" mean?
- 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. 16, Git explicitly warns you about this situation rather than silently ignoring the hook. hooksPath).
- How do I fix "hint: The '.git/hooks/pre-commit' hook was ignored because it's not se"?
- 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.
- What causes "hint: The '.git/hooks/pre-commit' hook was ignored because it's not se"?
- The hook file was created without the executable bit set (common when creating files on Windows) The repository was cloned or created on Windows and opened on Linux/macOS The hook file was copied manually without preserving permissions
- Is the "hint: The '.git/hooks/pre-commit' hook was ignored because it's not se" error serious?
- It is a low-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐Git Official Documentation
- ๐
- ๐
- ๐ฌ
- ๐ฌStack Overflow: git pre commit hook is not running on windows(Stack Overflow)
- ๐ฌStack Overflow: git hook permission denied(Stack Overflow)
- ๐GitHub #1177: typicode/husky(GitHub)
- ๐GitHub #1301: typicode/husky(GitHub)
- ๐
- ๐
- ๐