brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: core.fileMode false makes git ignore permission changes

Git
~/tips/tip-git-core-filemode-permission-noise

git config core.fileMode false

Stops git from reporting files as changed when only their executable bit changed.

After copying a project from a USB stick or a network share, every file can suddenly show as modified in git status. Often the content is the same and only the permissions changed.

git diff
old mode 100644
new mode 100755
git config core.fileMode false

The diff gives it away: old mode and new mode with no content change. With core.fileMode set to false, git stops looking at the executable bit and those files disappear from git status. Git sets this value itself when it creates or clones a repository, based on whether the file system supports the bit, so you mostly need it after copying a repository between systems.

I’d set it per repository, not globally. On a normal Linux or macOS disk, permissions are useful information.

A script that really should become executable then needs another way in, because git no longer notices chmod +x:

git update-index --chmod=+x deploy.sh

That sets the mode in the index, so the next commit stores the file as executable no matter what the disk says.

Keep in mind this only hides the difference on your machine. Git only tracks the executable bit, not other permissions or owners, so it was never a way to keep track of those in the first place.

Further reading: git-config documentation: core.fileMode, git-update-index documentation

More Git tips git show-branch main feature git log --stat -5 git merge --no-ff feature -m "Merge feature" git merge --squash feature git merge --abort All Git tips (144) All topics

Link