I am the only person involved with this git project. Every time I edit files at my local Ubuntu repository, then push to Bitbucket and pull to my production repository, git changes the edited files to -rwxrwxr-x 775. Apache doesn't like this.
Local system: git version 1.8.1.2 on Ubuntu Linux
Production system: git version 1.7.12 on CentOS/Red Hat Linux
When I fix permissions to 755, then do
git diff
or
git diff -p
It shows nothing.
At my local repository, the permissions are 755 and the files are all owned by haws. At my production repository, all other permissions stay at 755, and all files including contact.php are owned by my username.
At both the local and the production repository, I changed core.filemode as follows in an attempt to stop this behavior,
core.filemode = false
I've had mysteries like this in collaborative projects, so I'd really like to understand what's happening.
- What can I do to see git's reason for changing the permissions of this file?
- How can I get git to stop changing it?
I have also tried to find the solution here: Prevent Git from changing permissions on pull to no avail.
My Final Solution (thanks to VonC's guidance):
Thanks to VonC's good explanations, I was brave enough to figure out that every time I was logging into my server, my umask was going back to 0002. So I created a user startup script (.bashrc or in my case .bash_profile) at my Linux host that sets
umask 0022
or using symbolic notation (for a little added value)
umask u=a,g-w,o-w
or
umask u=a,go-w
(Allow all permissions for user, disallow write permissions for group and others)
That solved my issue.
- I had previously set git config core.sharedRepository true, but that was not my issue, and I removed the setting once the issue was resolved.