Git Ignore File Permission

Using Ubuntu for web development is a perfect match. Since i migrate to Ubuntu a month ago, i could code faster and deliver more result. Instead of great environment, i also found an issue with Git and File Permission. By default Git detect file permission, and if i change a file or directory permission then Git will track it and consider it as new changes. In Windows environment, i never found this issue.

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

After stumble a while on Stackoverflow, i found the answer here. We can change the git config to not track the file permission. All you need is run this command:

git config core.fileMode false

And you can make it as 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 change the code.fileMode to false, git no longer track for file permission change.

So if you have any feedback please leave your message below and i would love to discuss more and sharing knowledge together.

Comments

  1. Vitaliy Koziy says:

    Hi. I did
    git config core.fileMode false
    and this
    git config –add –global core.filemode false
    And I set for my project folder user apache and grouup apache.
    I did
    sudo -u apache git pull origin master
    on server side
    and after this files has changed permissions, from 755 to 644 or to 666,

    How to fix this shit?
    Thank You.

  2. Alex says:

    This works perfectly, thank you!

Give me your feedback

This site uses Akismet to reduce spam. Learn how your comment data is processed.