Search code examples
gitgit-submodules

git submodule foreach not working


I want to figure out why git submodule foreach command is not working for me. I have cloned a git repository which has several submodules. I wanted to init and update all submodules at once to pull down the submodules sources. But whatever I try git submodule foreach is not working for me... I tried several things:

git submodule foreach init
git submodule foreach update
git submodule foreach update --init
git submodule foreach --recursive git submodule update --init

Every command will execute but without any output... If I go and init/update each module separately (without using foreach) then no problem.

Any ideas?


Solution

  • git submodule init or git submodule update are supposed to work for all submodules registered in .gitmodules, so it doesn't make sense to execute them for each submodules.

    If you had submodules within submodules, git submodule update --recursive would take care of all submodules recursively.