Git Ignore File Permission

Using Ubuntu for web development is a perfect match. Since I migrated to Ubuntu a month ago, I could code faster and deliver more results. Along with the great environment, I also found an issue with Git and file permissions. By default Git detects file permissions, and if I change a file or directory permission then Git will track it and consider it as new changes. In a Windows environment, I never found this issue.

And since I’m also using suPHP libraries on my LAMP stack, I must use 755 file permissions. After cloning a repository, I always find a SoftException error because my files are writable by the user group, which suPHP doesn’t allow. Therefore I need to change all the file and directory permissions to 755. After changing the permissions, Git finds all the file changes and I need to add and commit them all. This is not good.

After stumbling around on Stack Overflow, I found the answer here. We can change the git config to not track file permissions. All you need is to run this command:

git config core.fileMode false

And you can make it a global config with the command below:

git config --add --global core.filemode false

And see the documentation here:

core.fileMode
 If false, the executable bit differences between the index and the
 working copy are ignored; useful on broken filesystems like FAT.
 See git-update-index(1). True by default.

So after I changed the core.fileMode to false, git no longer tracks file permission changes.

If you have any feedback please leave your message below and I would love to discuss more and share knowledge together.