Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pull git submodules after cloning project from GitHub

People also ask

Does git clone pull submodules?

It automatically pulls in the submodule data assuming you have already added the submodules to the parent project. Note that --recurse-submodules and --recursive are equivalent aliases.

What does git pull -- recurse submodules do?

git submodule foreach git pull origin master or git pull origin master --recurse-submodules is what you want if you intend to update each submodule to the latest from their origin repositories. Only then will you get pending changes in the parent repo with updated revision hashes for submodules.


From the root of the repo just run:

git submodule update --init

If you need to pull stuff for submodules into your submodule repositories use

git pull --recurse-submodules

But this will not checkout proper commits(the ones your master repository points to) in submodules

To checkout proper commits in your submodules you should update them after pulling using

git submodule update --recursive

If there are nested submodules, you will need to use:

git submodule update --init --recursive

I just want to share these.

First way,
git submodule init && git submodule update

The below is just basically combining the first way,
git submodule update --init

If there are any nested submodules, Iglesk's answer is the way to go.