git: how can i config git to ignore file permissions changes

21

7

I have some git projects in a linux server.

i use Mac and linux to do my programming. the problem is that the mac filesystem's permissions doesn't really work well like in linux so all the files seems to be on umask 0755. so whenever i pull my code on my mac, git status shows that all my files are changed and when i use git diff it shows that the only change is in the umask. how can i tell git not to store and check for umask changes ?

thanks!

ufk

Posted 2011-03-22T21:54:56.710

Reputation: 1 055

1I'm quite sure OS X supports Unix-style permissions... – user1686 – 2011-03-22T22:15:14.407

1umask and permissions aren't the same thing. Are you sure you really know what you're doing here? – Marnen Laibow-Koser – 2014-03-22T15:22:50.683

Answers

28

Set the core.fileMode configuration property to false. You can do this easily with this command:

git config core.fileMode false

Patches

Posted 2011-03-22T21:54:56.710

Reputation: 14 078

Is this a per-repository setting or is it possible to make this work globally? – acme – 2012-01-18T15:24:20.257

2@acme: Like all git settings, you can set it per-repository, per user, or systemwide, by passing no extra switch, --global, or --system, respectively. See git help config for details. – Patches – 2012-01-20T04:06:10.527

Thanks! But setting it globally does not automatically add this setting to new repositories, it's just a setting on my local machine? – acme – 2012-03-01T11:22:25.850

@acme: Yup, setting an option with --global affects all operations on any repository accessed with your user account locally. It doesn't affect anyone else. To set it for all users of a particular repository you'd have to toggle the per-repository setting on the server everyone pushes to. – Patches – 2012-03-02T05:30:53.550

1

I have a small shell script to toggle this

cat ~/bin/git-ignore-chmod-toggle

#!/bin/bash
# Copyright 2015 Alexx Roche, MIT license.
# based on http://superuser.com/a/261076

gitCHMODstate=$(git config --get core.fileMode)

# toggle with git config core.fileMode true 

if [ $gitCHMODstate == 'true' ];then
    echo "git now ignores file mode (chmod)"
    git config core.fileMode false
else
    echo "git not looks for files modes changed with chmod"
    git config core.fileMode true
fi

With this I can toggle git, check for other changes and then put back on quickly.

Alexx Roche

Posted 2011-03-22T21:54:56.710

Reputation: 760