1 2 |
git config core.fileMode false |
From git-config(1):
12345 core.fileModeIf false, the executable bit differences between the index and theworking copy are ignored; useful on broken filesystems like FAT.See git-update-index(1). True by default.
The -c
flag can be used to set this option for one-off commands:
1 2 |
git -c core.fileMode=false diff |
And the --global
flag will make it be the default behavior for the logged in user.
1 2 |
git config --global core.fileMode false |
Warning
core.fileMode
is not the best practice and should be used carefully. This setting only cover the executable bit of mode and never the read/write bits. In many cases you think you need this settings because you did something like chmod -R 777
, making all your files executable. But in most projects most files don’t need and should not be executable for security reasons.
The proper way to solve this kind of situation is to handle folder and file permission separately, with something like:
1 2 |
<span class="pln">find </span><span class="pun">.</span> <span class="pun">-</span><span class="pln">t d </span><span class="pun">-</span><span class="pln">exec chmod a</span><span class="pun">+</span><span class="pln">rwx \; </span><span class="com"># Make folders traversable and read/write</span><span class="pln"> find </span><span class="pun">.</span> <span class="pun">-</span><span class="pln">t f </span><span class="pun">-</span><span class="pln">exec chmod a</span><span class="pun">+</span><span class="pln">rw \; </span><span class="com"># Make files read/write</span> |
If you do that, you’ll never need to use core.fileMode
, except in very rare environment.
NOTE:
If above does not work for you, your local repo might have a config that already has
1 |
filemode = true |
and the global config will never work as the local config is much more priority. To do that, cd into your local project folder like so:
1 2 |
cd .git vi config |
and change the filemode directive to false:
1 2 3 |
[core] repositoryformatversion = 0 filemode = false |
That’s it!
REF: https://stackoverflow.com/questions/1580596/how-do-i-make-git-ignore-file-mode-chmod-changes
Be First to Comment