Easy Way To Pull All Git Submodules

UPDATE - 04 DEC 2019

For git 2.23.0 now you can colone, initialize all submodules and also pull the content from remote with single command:

git clone --recurse-submodules --remote-submodules git@github.com:username/repository.git

No more hasle!

The solution below is originally from that link, posted by a user jjmontes.

For git 1.8.2 or above the option --remote was added to support updating to latest tips of remote branches:

git submodule update --recursive --remote

For git 1.7.3 or above you can use (but the below gotchas around what update does still apply):

git submodule update --recursive

If you want to pull your submodules to latest commits instead of what the repo points to, you can use this command:

git pull --recurse-submodules

Note: If that's the first time you checkout a repo you need to use –init first:

git submodule update --init --recursive

For older, git 1.6.1 or above you can use something similar to (modified to suit):

git submodule foreach git pull origin master

See git-submodule(1) for details.