Home > other >  Git submodule ignore error at branch checkout when that submodule does not have that branch
Git submodule ignore error at branch checkout when that submodule does not have that branch

Time:03-02

I have 6 sub modules in a git repository, says submodule1, submodule2,... submodule6. On 4 sub modules: submodule1/2/4/5 I have a branch, says featureABC, on them.

When I run the checkout command:

$ git submodule foreach git checkout featureABC

there is an errror:

error: pathspec 'featureABC' did not match any file(s) known to git
fatal: run_command returned non-zero status for submodule3

I know that submodule3/6 do not have branch featureABC and I want to ignore them when run recursive checkout. So my question is: is there any way to ignore checkout error, leave the branch of submodule3/5 as it is and continue to other submodule checkout?

CodePudding user response:

Ignore all errors with this shell syntax:

git submodule foreach "git checkout featureABC || :"

: means "do nothing".

  • Related