Easy way to pull latest of all git submodules
If it's the first time you check-out a repo you need to use --init
first:
git submodule update --init --recursive
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
This has the added benefit of respecting any "non default" branches specified in the .gitmodules
or .git/config
files (if you happen to have any, default is origin/master, in which case some of the other answers here would work as well).
For git 1.7.3 or above you can use (but the below gotchas around what update does still apply):
git submodule update --recursive
or:
git pull --recurse-submodules
if you want to pull your submodules to latest commits instead of the current commit the repo points to.
See git-submodule(1) for details
git pull --recurse-submodules --jobs=10
a feature git first learned in 1.8.5.
Until the bug is fixed, for the first time you do need to run
git submodule update --init --recursive
On init running the following command:
git submodule update --init --recursive
from within the git repo directory, works best for me.
This will pull all latest including submodules.
Explained
git - the base command to perform any git command
submodule - Inspects, updates and manages submodules.
update - Update the registered submodules to match what the superproject
expects by cloning missing submodules and updating the working tree of the
submodules. The "updating" can be done in several ways depending on command
line options and the value of submodule.<name>.update configuration variable.
--init without the explicit init step if you do not intend to customize
any submodule locations.
--recursive is specified, this command will recurse into the registered
submodules, and update any nested submodules within.
After this you can just run:
git submodule update --recursive
from within the git repo directory, works best for me.
This will pull all latest including submodules.