I have a project in which I have to change the mode of files with chmod
to 777 while developing, but which should not change in the main repo.
Git picks up on chmod -R 777 .
and marks all files as changed. Is there a way to make Git ignore mode changes that have been made to files?
If you have used chmod command already then check the difference of file, It shows previous file mode and current file mode such as:
new mode : 755
old mode : 644
set old mode of all files using below command
sudo chmod 644 .
now set core.fileMode to false in config file either using command or manually.
then apply chmod command to change the permissions of all files such as
and again set core.fileMode to true.
For best practises don't Keep core.fileMode false always.
undo mode change in working tree:
Or in mingw-git
If you want to set filemode to false in config files recursively (including submodules) :
find -name config | xargs sed -i -e 's/filemode = true/filemode = false/'
You can configure it globally:
git config --global core.filemode false
If the above doesn't work for you, the reason might be your local configuration overrides the global configuration.
Remove your local configuration to make the global configuration take effect:
git config --unset core.filemode
Alternatively, you could change your local configuration to the right value:
git config core.filemode false
By definining the following alias (in ~/.gitconfig) you can easily temporarily disable the fileMode per git command:
When this alias is prefixed to the git command, the file mode changes won't show up with commands that would otherwise show them. For example:
If
does not work for you, do it manually:
cd into .git folder:
edit the config file:
change true to false
->
save, exit, go to upper folder:
reinit the git
you are done!