.git changing file permission issue [Solved]

Category : Advanced

Many a times users run into the issue of .git changing their file permission on doing ‘git pull’ on server/remote machine.

This causes issue with the writable group permission and might even give you Server Internal Error 500.

1) In case you want your GIT not to track the file permission changes, run the following command :

git config core.fileMode false
git init

Make sure it’s fileMode (case sensitive).

Alternatively you can open your config file also :


cd goto/rootdirectory
cd .git
nano config

You will get something like this :

[core]
repositoryformatversion = 0
filemode = false
bare = false

Change your filemode to false if it’s true and save file.

2) In case still the issue persist, then it can be your ‘umask’ at fault.

Type command :

umask

If it returns 0002 , changing it to 0022 by tying command :

umask 0022

To changing the default umask (as it will get reset on every login to your server) , use following command:

$ vi ~/.bashrc

Append/modify following line to setup a new umask:
umask 022

Save file and you should be good to go. 🙂

In case you are messed up with file permission of the project, use the following two commands to fix it up :

find basezapfolder -type d -exec chmod 755 {} \;
find basezapfolder -type f -exec chmod 644 {} \;

This will recursively change all the folder permission to 755 ( including all the folder residing inside of basezapfolder).

This will recursively change all the folder permission to 644 (including all the files residing inside of basezapfolder).