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

GitBEGINNERLOWUpdated Dec 6, 2025ยท 193 views

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
  1. Make the hook file executable
  2. Verify the file has executable permissions
  3. For Windows users: Use git add --chmod
  4. Check if the hooks directory is correct
git โ€” error
chmod +x .git/hooks/pre-commit
hint: 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

  1. The hook file was created without the executable bit set (common when creating files on Windows)
  2. The repository was cloned or created on Windows and opened on Linux/macOS
  3. The hook file was copied manually without preserving permissions
  4. The file system is mounted with the noexec flag, preventing any executable permissions
  5. Git's core.fileMode is set to false, causing permission changes to be ignored
  6. 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"

1Make the hook file executable

Run the chmod command to add the executable bit to your pre-commit hook:

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

If you have multiple hooks that need to be fixed:

bash
chmod +x .git/hooks/*

This is the most common fix and works on Linux and macOS.

2Verify the file has executable permissions

Check the current permissions on your hook file:

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

You should see an 'x' in the permissions, like:

bash
-rwxr-xr-x 1 user user 1234 Jan 1 12:00 pre-commit

If the file shows -rw-r--r-- (no x), it's not executable.

3For Windows users: Use git add --chmod

On Windows, the file system doesn't support Unix-style permissions. Use Git's built-in option to set the executable bit:

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

Alternatively, if you're using Git Bash, the chmod command should still work:

bash
chmod +x .git/hooks/pre-commit
4Check if the hooks directory is correct

Verify which hooks directory Git is using:

bash
git config core.hooksPath

If this returns a custom path (like .husky), make sure the hooks in that directory are executable:

bash
chmod +x .husky/pre-commit

If core.hooksPath is not set, Git uses .git/hooks/ by default.

5For Husky users: Fix permissions in package.json

If you're using Husky for Git hooks, add a prepare script that ensures hooks are executable:

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

Then run:

bash
npm run prepare

This ensures hooks are executable after installation on any Unix-based system.

6Check file system mount options

If chmod doesn't work, your file system might be mounted with the noexec flag. Check mount options:

bash
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

7Disable the warning (not recommended)

If you intentionally want hooks to be non-executable (to disable them), you can suppress the warning:

bash
git config advice.ignoredHook false

Note: 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:

bash
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:

bash
# 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:

bash
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