Git update submodules recursively
git submodule update --recursive
You will also probably want to use the --init option which will make it initialize any uninitialized submodules:
git submodule update --init --recursive
Note: in some older versions of Git, if you use the --init
option, already-initialized submodules may not be updated. In that case, you should also run the command without --init
option.
The way I use is:
git submodule update --init --recursivegit submodule foreach --recursive git fetchgit submodule foreach git merge origin master
As it may happens that the default branch of your submodules are not master
(which happens a lot in my case), this is how I automate the full Git submodules upgrades:
git submodule initgit submodule updategit submodule foreach 'git fetch origin; git checkout $(git rev-parse --abbrev-ref HEAD); git reset --hard origin/$(git rev-parse --abbrev-ref HEAD); git submodule update --recursive; git clean -dfx'