'git submodule update --init --recursive' VS 'git submodule foreach --recursive git submodule update --init'
git, git-submodules
Solution
git submodule update --init --recursive
The submodule `update` command will recurse into the registered submodules, update and init (if required) them and any nested submodules within.
git submodule foreach --recursive git submodule update --init
`foreach` will evaluate the command in each checked out submodule. So it will update and init (if required) each submodule and any nested submodules within due to `--recursive`.
So in the end, both commands will achieve the same thing. Simply the execution differs, the first command won't step into each directory to execute the command.
Problem
I have git repo which has nested submodules. What is the difference between below 2 commands? ``` git submodule update --init --recursive git submodule foreach --recursive git submodule update --init ```