Ignore executable-bit changes in Git

Use core.fileMode to suppress unreliable working-tree executable-bit changes, then set intentional script modes explicitly in the index.

Best practices
Illustration of application troubleshooting

Set core.fileMode to false when your filesystem or mount reports unreliable executable-bit changes:

git config core.fileMode false

This tells Git to ignore differences in the executable bit when comparing working-tree files with the index. Git does not track the full set of Unix permissions, ownership, or ACLs, so this is not a general permission-management setting.

Choose the configuration scope

# This repository only
git config core.fileMode false

# Your global default
git config --global core.fileMode false

# Inspect the effective value and its source
git config --show-origin --get core.fileMode

Repository configuration overrides the global default. Git normally probes filesystem behavior during initialization or cloning, so a local setting may already exist. Do not disable mode checks solely because a machine runs Windows; investigate the actual diff and filesystem behavior.

Shared mounts, copied checkouts, or deployment tools that alter executable bits are common reasons to inspect this setting.

Distinguish working-tree changes from staged modes

An existing unstaged mode-only difference can disappear from status immediately after setting core.fileMode=false. You do not need to run git checkout ., which could discard unrelated file-content edits.

A mode change already recorded in the index remains staged. Compare the two separately:

git diff --summary
git diff --cached --summary

To record the intended executable state explicitly:

git update-index --chmod=+x -- deploy.sh
# Or record a non-executable file:
git update-index --chmod=-x -- data.txt

These commands update index modes even with core.fileMode=false. Review and commit the result. They do not necessarily change the working-tree file's permissions; use an operating-system permission command when the local file itself needs adjustment.

New files also need attention

Do not assume a newly added executable script will retain its executable mode when mode detection is disabled. Check the staged mode with git ls-files --stage -- deploy.sh and set it deliberately when needed. A regular tracked file typically uses 100644 or 100755 for the non-executable or executable form.

FAQ

Why do content changes or CRLF markers remain?

core.fileMode affects executable-bit detection, not text contents. Inspect line-ending rules such as .gitattributes and core.autocrlf separately.

Can the repository enforce this for everyone?

The setting lives in Git configuration rather than in committed project files. Document any required setup. Keep executable-bit tracking enabled where the filesystem supports it reliably.

Does this fix a production permission-denied error?

No. It changes Git's comparison behavior, not runtime access permissions. Inspect the deployed file, interpreter, user, and application logs. Guance's log collector documentation covers collecting those diagnostics when needed.

See git-config and git-update-index.

Get a tailored plan

Contact us

Join the community

Scan with WeChat
to join the community

Try Guance

Start online and pay only for what you use.

Get started

Choose a Guance plan

Code hosting