Git config filemode false for ignore file mode (chmod) changes

Here we describe git config core.filemode false code example for ingnore file mode chmod changes. More then times we need to give permission the folder but the files are showing in git, then we need to don’t show the chmod chnages and ignore the files.

Git picks up on chmod -R 777 . and marks all files as changed so we need to a best way to make Git ignore mode changes that have been made to files. Let’s see the best command for configure git to ignore file mode changes.

Ignore Filemode Changes:

Run the following within the repository to ignore the changes:

git config core.fileMode false

The -c flag can be used to set this option for one-off commands:

git -c core.fileMode=false diff

And the --global flag will make it be the default behavior for the logged in user.

git config --global core.fileMode false

Changes in the global setting won’t be applied to existing repositories. You have to either clone the repository again or execute git init. It will not overwrite things that are already there.


core.fileMode is not the best practice and should be used carefully. This setting only covers the executable bit of mode and never the read/write bits. In many cases you think you need this setting 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:

find . -type d -exec chmod a+rwx {} \; # Make folders traversable and read/write
find . -type f -exec chmod a+rw {} \;  # Make files read/write

If you do that, you’ll never need to use core.fileMode, except in very rare environment.


Leave a Comment