Preventing Git from tracking files which have changed permissions

Preventing Git from tracking files which have changed permissions

Development

Git

Published: February 28, 2024

Author: Andrew Arscott

Git is an excellent tool for managing your code, tracking changes and collaborating, but sometimes it can go a little too far.

If you ever run git status and then suddenly you find every file in your code base is being marked as modified, but you have not actually made any changes, then it is probably because the files permissions have changed.

git changes

Now generally speaking you should not be changing your file permissions en mass, certainly not in a production environment, but if in development you have permission issues, which if you develop using WSL2, and have at some point run sudo chmod -R 777 then you might find yourself in this situation.

Git has a config item you can toggle to make it ignore executable files permission changes, simply run:

git config core.fileMode false

and your git diff will now only track files which have actually changed, and not if they have had their permission changed.