Search code examples
gitchmod

In git, how to unset core.fileMode for each submodule?


here is the result of my attempt:

$
git submodule foreach --recursive "git config --unset core.fileMode"
Entering 'buildSrc'
fatal: run_command returned non-zero status for buildSrc

my questions are:

  • what's the cause of the non-zero status?
  • how to fix it?

Solution

  • $ git init test-git
    $ cd test-git
    $ git config core.fileMode
    true
    $ git config --unset core.fileMode; echo $?
    0
    $ git config --unset core.fileMode; echo $?
    5
    

    That is, you cannot unset value which is not set, Git returns an error code. This is the answer for your 1st question.

    For the 2nd question: you need to ignore errors:

    git submodule foreach --recursive "git config --unset core.fileMode || :"
    

    : in shells means noop, "do nothing". I.e., the command is "git config --unset or do nothing in case of errors".