Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git update submodules recursively

My project struture

ProjectA -FrameworkA (submodule) --Twig (submodule of FrameworkA) 

How I can update submodules recursively? I already tried some git commands (on ProjectA root)

git submodule foreach git pull origin master 

or

git submodule foreach --recursive git pull origin master 

but cannot pull files of Twig.

like image 598
complez Avatar asked Apr 16 '12 03:04

complez


People also ask

How do I update a submodule in git recursive?

If you already cloned the project and forgot --recurse-submodules , you can combine the git submodule init and git submodule update steps by running git submodule update --init . To also initialize, fetch and checkout any nested submodules, you can use the foolproof git submodule update --init --recursive .

What is git submodule update -- init -- recursive?

git submodule update --init --recursive --remote - updates all submodules recursively along their tracking branches. Without the --remote , it'll reset the submodule working directories to the "right" commit for the parent.

Will git pull update submodules?

Once you have set up the submodules you can update the repository with fetch/pull like you would normally do. To pull everything including the submodules, use the --recurse-submodules and the --remote parameter in the git pull command .


2 Answers

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.

like image 170
drewag Avatar answered Oct 11 '22 21:10

drewag


The way I use is:

git submodule update --init --recursive git submodule foreach --recursive git fetch git submodule foreach git merge origin master 
like image 35
William Entriken Avatar answered Oct 11 '22 20:10

William Entriken