Git submodule inside of a submodule (nested submodules)

Is it possible for a git submodule to be made of several other git submodules, and the super git repo to fetch the contents for each submodule?

I have tried to do this using the obvious/naive approach of creating a git repo holding several submodules.

Then adding this git repo to another git repo as a submodule.

Then attempting to pull from the root directory of the super git repo by git submodule init and then git submodule update. But this fails to fetch the sub-submodules.

“git submodule” comes back empty

i use the following sequence to initialize and update git submodules: git init git submodule init git submodule update Then I want to see all the submodules, by this command: git submodule It prints

git submodule update specific submodule only

So, updating all my submodules is done by running git submodule foreach ‘git pull origin master’ How do I update a specific submodule, located in say bundle/syntastic, without updating any other subm

GIT submodule update * deletes uncommited files

I have a GIT repository and inside several SUBMODULES. The problem is every time someone updates submodule, I try to update my files by calling: $ git submodule update But what happens is it deletes

Continue looping over submodules with the “git submodule foreach” command after a non-zero exit

I have a project that contains many submodules. I want to loop over each submodule with the following command: git submodule foreach npm install And I want the script to continue looping over each sub

Git update submodule recursive

My project struture ProjectA -FrameworkA (submodule) –Twig (submodule of FrameworkA) How I can update submodule recursive? I already tried some git commands (on ProjectA root) git submodule foreach

Git submodule init async

When I run git submodule update –init first time on a projects which have a lot of submodules, this usually take a lot of time, because most of submodules are stored on slow public servers. Is there

git submodule not pulling files in submodules

I thought I had it all worked out with this new project and thought that git submodules are the way to to develop and deploy my application. Set up my git repo (Drupal) and initialized it with the 7.1

git submodule update

I’m not clear on what the following means (from git submodule update docs): …will make the submodules HEAD be detached, unless –rebase or –merge is specified… How does –rebase/–merge chang

git dependency hell? — submodule pull failing

What am I doing wrong here? $ git submodule foreach git pull # fails $ cd Submodules/MBProgressHUD/ $ git diff $ git checkout master $ git pull $ cd .. $ cd .. $ git submodule foreach git pull # fails

git submodule foreach not working

I want to figure out why git submodule foreach command is not working for me. I have cloned a git repository which has several submodules. I wanted to init and update all submodules at once to pull do

Answers

As Sridhar comments below, from Git1.6.5+, git clone –recursive is now the official alternative, described in:

inamiy correctly points out the git submodule update –init –recursive command, introduced in commit b13fd5c, again in git1.6.5, by Johan Herland (jherland).


(older original answer)

According to the manual page

 git submodule update --recursive

should update any nested submodules. But the init part may not be recursive.

Depending on your version of Git, you could fall back to a more “scripting” approach, with this article Recursively Updating Git Submodules which allows for recursive init and update:

#!/usr/bin/perl

use strict;
use Cwd;

init_and_update();

exit;

sub init_and_update
{
    my $start_path = cwd();

    my %paths;
    my $updated;

    do
    {
        my $data = `find . -name '.gitmodules'`;
        chomp($data);

        $data =~ s////.gitmodules//g;

        foreach my $path (split(//n/, $data))
        {
            $paths{$path} = '' if($paths{$path} eq '');
        }

        $updated = 0;

        foreach my $path (sort keys %paths)
        {
            if($paths{$path} eq '')
            {
                chdir($path);
                `git submodule init 2>&1`;
                `git submodule update 2>&1`;
                chdir($start_path);

                if($ARGV[0] eq '--remove-gitmodules')
                {
                    unlink("$path/.gitmodules");
                }

                $paths{$path} = 1;

                $updated++;
            }
        }
    } while($updated);
}

As mentioned in Retrospectively add –recursive to a git repo

git submodule update --init --recursive

should work.