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 pick
Adding to Greg Hewgill answer (of using core.fileMode
config variable):
You can use --chmod=(-|+)x
option of git update-index (low-level version of "git add") to change execute permissions in the index, from where it would be picked up if you use "git commit" (and not "git commit -a").
This works for me:
find . -type f -exec chmod a-x {} \;
or reverse, depending on your operating system
find . -type f -exec chmod a+x {} \;
If you want to set this option for all of your repos, use the --global
option.
git config --global core.filemode false
If this does not work you are probably using a newer version of git so try the --add
option.
git config --add --global core.filemode false
If you run it without the --global option and your working directory is not a repo, you'll get
error: could not lock config file .git/config: No such file or directory
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