Vigh Iosif Vigh Iosif - 2 years ago 135
Git Question

set a Git config recursively for all submodules

I need to run the command:

git config core.filemode false


The problem is that I have a few projects with at least ten submodules each. For some reason, all the submodules have that value set to true so I would have to remove/update that config manually.

Is there a way to tell Git to set a config value to all submodules?

Or remove it from the submodules so that the containing repo's settings are not overwritten?

Answer Source

You can use the git submodule foreach command for this: https://www.kernel.org/pub/software/scm/git/docs/v1.6.1.3/git-submodule.html

You can provide an arbitrary shell command as a parameter, in your case something like this:

git submodule foreach --recursive git config core.filemode false

This will execute git config core.filemode false in each of the submodules of the current Git repo.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download