+4 votes
1 view
in DevOps and Agile by (30k points)

We're using git submodules to manage a couple of large projects that have dependencies on many other libraries we've developed. Each library is a separate repo brought into the dependent project as a submodule. During development, we often want to just go grab the latest version of every dependent submodule.

Does git have a built-in command to do this? If not, how about a Windows batch file or similar that can do it?

1 Answer

+2 votes
by (51.2k points)
edited by

If it’s your first time you need to initiate submodules on their repository for this use 

git submodule update --init --recursive

If git version is above 1.8.2 then add --remote which looks like

git submodule update --init --recursive --remote

--remote will add non-default branches to specified files in .gitmodules or .git/config

For git version 1.7.3 and above use 

git submodule update --recursive


git pull --recurse-submodules

if you want to pull your submodules to the latest commits instead of what the repo points to

Reference: https://git-scm.com/docs/git-submodule

For more information please go through the following tutorial to get more info about git:

by (5.8k points)
Helpful. Thanks.

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !