How to fix hint: The pre-commit hook was ignored because it's not set as executable in Git

GitBEGINNERLOWUpdated Dec 6, 2025ยท 147 views

This Git warning appears when a pre-commit hook file exists but lacks executable permissions. Git detects the hook but cannot run it. The fix is to make the hook file executable with chmod.

Quick fix

Fixes hint: The pre-commit hook was ignored because it's not set as executable

chmod +x .git/hooks/pre-commit
  1. Make the pre-commit hook executable
  2. Verify the hook is now executable
  3. For Husky users: Recreate hooks properly
  4. Automate permissions in package.json (Node.js projects)
git โ€” error
chmod +x .git/hooks/pre-commit
hint: The pre-commit hook was ignored because it's not set as executable

What this error means

When you commit changes in Git, it checks for hook scripts in the `.git/hooks/` directory (or a custom hooks path). These hooks allow you to run custom scripts at various points in the Git workflow, such as before a commit is finalized. Git detected a `pre-commit` hook file in your hooks directory, but the file doesn't have the executable permission bit set. On Unix-like systems (Linux, macOS), files need to be marked as executable to be run as scripts. Without this permission, Git cannot execute the hook and displays this warning instead. This commonly occurs when: - Hook files are copied or created manually without setting permissions - Files are cloned from a Windows machine where executable bits are not preserved - You're using Husky or another hook manager that didn't set permissions correctly - The file was added to Git on Windows and checked out on Linux/macOS

Typical symptoms

  • Git displays 'hint: The pre-commit hook was ignored...' during commits
  • Pre-commit checks (linting, tests) don't run before commits
  • Commits succeed without expected validation steps
  • Warning appears on Linux/macOS but not on Windows
  • Issue appears after cloning a repository to a new machine

Common causes

  1. Hook file lacks executable permission (most common)
  2. Hook was created manually instead of using husky add or similar command
  3. Repository cloned from Windows to Linux/macOS without preserving permissions
  4. File system doesn't support executable permissions (NTFS mounted on Linux)
  5. Husky or pre-commit tool not configured correctly after install
  6. Git hooks path (core.hooksPath) points to non-executable files

How to fix "hint: The pre-commit hook was ignored because it's not set as executable"

1Make the pre-commit hook executable

The most direct fix is to add the executable permission to the hook file:

bash
chmod +x .git/hooks/pre-commit

If you're using Husky (hooks in .husky/ directory):

bash
chmod +x .husky/pre-commit

To make all hooks executable at once:

bash
chmod +x .git/hooks/*
chmod +x .husky/*
2Verify the hook is now executable

Check that the permission was set correctly:

bash
ls -la .git/hooks/pre-commit

You should see -rwxr-xr-x or similar (the x indicates executable). The output should look like:

bash
-rwxr-xr-x 1 user user 478 Jan 15 10:30 .git/hooks/pre-commit

Now try a commit to confirm the hook runs:

bash
git commit --allow-empty -m "Test hook"
3For Husky users: Recreate hooks properly

If you manually created the hook file, it won't have executable permissions. Remove it and use Husky's command:

bash
rm .husky/pre-commit
npx husky add .husky/pre-commit "npm test"

Or with Yarn:

bash
yarn husky add .husky/pre-commit "yarn test"

This creates the file with correct permissions (755).

4Automate permissions in package.json (Node.js projects)

Add chmod to your prepare script to ensure permissions are set after install:

json
{
  "scripts": {
    "prepare": "husky install && chmod ug+x .husky/*"
  }
}

This runs automatically when team members run npm install or yarn install, fixing permissions on all machines.

5Check and fix Git hooks path

If you have a custom hooks path configured, ensure it points to the correct location:

bash
git config --get core.hooksPath

If this returns an unexpected path, you can reset it:

bash
git config --unset core.hooksPath

Or set it to your hooks directory:

bash
git config core.hooksPath .husky

Advanced notes

### Windows to Linux/macOS Migration

When hooks are created on Windows and pushed to a repository, the executable bit isn't preserved because Windows doesn't have the same permission model. When these are cloned on Unix systems, they won't be executable.

Solution for teams: Add a post-checkout or prepare script that sets permissions:

bash
# In package.json
"postinstall": "chmod +x .husky/* 2>/dev/null || true"

### File System Limitations

If you're working on an NTFS partition mounted in Linux (common with dual-boot setups), the mount options may not support executable permissions. Check your /etc/fstab or mount options:

bash
mount | grep ntfs

You may need to remount with exec option or work from a native Linux filesystem.

### Disabling the Warning (Not Recommended)

You can suppress the warning without fixing it:

bash
git config advice.ignoredHook false

Warning: This only hides the message. Your hooks still won't run, defeating their purpose.

### pre-commit Framework Users

If you use the pre-commit Python framework instead of Husky:

bash
pre-commit install --install-hooks

This properly installs hooks with correct permissions. If hooks still fail:

bash
pre-commit clean
pre-commit install

### Git Executable Bit Tracking

Git can track the executable bit. To preserve permissions across clones:

bash
git update-index --chmod=+x .husky/pre-commit
git commit -m "Make pre-commit hook executable"

This ensures the file is executable for everyone who clones the repository.

Frequently asked questions

What does "hint: The pre-commit hook was ignored because it's not set as executab" mean?
git/hooks/ directory (or a custom hooks path). These hooks allow you to run custom scripts at various points in the Git workflow, such as before a commit is finalized. Git detected a pre-commit hook file in your hooks directory, but the file doesn't have the executable permission bit set.
How do I fix "hint: The pre-commit hook was ignored because it's not set as executab"?
This Git warning appears when a pre-commit hook file exists but lacks executable permissions. Git detects the hook but cannot run it. The fix is to make the hook file executable with chmod.
What causes "hint: The pre-commit hook was ignored because it's not set as executab"?
Hook file lacks executable permission (most common) Hook was created manually instead of using husky add or similar command Repository cloned from Windows to Linux/macOS without preserving permissions
Is the "hint: The pre-commit hook was ignored because it's not set as executab" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading