# cloning submodules with children submodules

3 messages from 2007-11-23 to 2007-11-23. Participants: Paul Martinolich, Sven Verdoolaege.
Thread: https://gitlist.dev/t/10996

## Paul Martinolich, 2007-11-23 19:17

Subject: cloning submodules with children submodules
Message-ID: <BC1DE15A-9225-41D3-A2D7-21A14DF81048@nrlssc.navy.mil>
URL: https://gitlist.dev/e/BC1DE15A-9225-41D3-A2D7-21A14DF81048%40nrlssc.navy.mil

```
It appears that git clone or git submodule init does not handle  
submodules under submodules.

Given this project tree:

modules/mod_A
modules/mod_B
modules/mod_b

proj_one/mod_A
proj_one/mod_B
proj_one/mod_B/mod_b

proj_two/mod_A
proj_two/mod_B
proj_two/mod_b

The cloning of proj_two works correctly.  However, for proj_one, mod_b  
is not under mod_B:

cloned proj_one

$ ls -a ./
.  ..  .git  .gitmodules  mod_A  mod_B	project.txt
$ ls -a ./mod_A
.  ..
$ ls -a ./mod_B
.  ..
$ more .gitmodules
[submodule "mod_A"]
	path = mod_A
	url = /home/martinol/test/modules/mod_A/.git
[submodule "mod_B"]
	path = mod_B
	url = /home/martinol/test/modules/mod_B/.git
Submodule 'mod_A' (/home/martinol/test/modules/mod_A/.git) registered  
for path 'mod_A'
Submodule 'mod_B' (/home/martinol/test/modules/mod_B/.git) registered  
for path 'mod_B'
Initialized empty Git repository in /home/martinol/test/user_a/ 
proj_one/mod_A/.git/
0 blocks
Submodule path 'mod_A': checked out  
'80298817a0789d039e1fb4a73c9635fce8e7cdd2'
Initialized empty Git repository in /home/martinol/test/user_a/ 
proj_one/mod_B/.git/
0 blocks
Submodule path 'mod_B': checked out  
'21b652610f5e9085f799c424d8a7ef685f5ec440'

submodule init/update proj_one

$ ls -a ./
.  ..  .git  .gitmodules  mod_A  mod_B	project.txt
$ ls -a ./mod_A
.  ..  .git  module.txt
$ ls -a ./mod_B
.  ..  .git  module.txt
$ more .gitmodules
[submodule "mod_A"]
	path = mod_A
	url = /home/martinol/test/modules/mod_A/.git
[submodule "mod_B"]
	path = mod_B
	url = /home/martinol/test/modules/mod_B/.git

public proj_one

$ cd ~/test/proj_one
$ ls -a ./
.  ..  .git  .gitmodules  mod_A  mod_B	project.txt
$ ls -a ./mod_B
.  ..  .git  .gitmodules  mod_b  module.txt
$ more .gitmodules
[submodule "mod_A"]
	path = mod_A
	url = /home/martinol/test/modules/mod_A/.git
[submodule "mod_B"]
	path = mod_B
	url = /home/martinol/test/modules/mod_B/.git
$ more mod_B/.gitmodules
[submodule "mod_b"]
	path = mod_b
	url = /home/martinol/test/modules/mod_b/.git

$ git --version
git version 1.5.3.6

I've attached a script that demonstrates this behavior.

Thanks, Paul








```

## Sven Verdoolaege, 2007-11-23 19:49

Subject: Re: cloning submodules with children submodules
Message-ID: <20071123194904.GL2261MdfPADPa@greensroom.kotnet.org>
URL: https://gitlist.dev/e/20071123194904.GL2261MdfPADPa%40greensroom.kotnet.org
In-Reply-To: <BC1DE15A-9225-41D3-A2D7-21A14DF81048@nrlssc.navy.mil>

```
On Fri, Nov 23, 2007 at 01:17:15PM -0600, Paul Martinolich wrote:
> It appears that git clone or git submodule init does not handle  
> submodules under submodules.

I don't see why it wouldn't work.

You seem to think, however, that git submodule update would
call git submodule update/init inside any submodules it clones.
It doesn't.

> The cloning of proj_two works correctly.  However, for proj_one, mod_b  
> is not under mod_B:

You didn't commit the change to mod_B to proj_one.
Furthermore, you didn't push your changes to mod_B to
the repo you specified for mod_B in .gitmodules.

skimo

```

## Paul Martinolich, 2007-11-23 20:35

Subject: Re: cloning submodules with children submodules
Message-ID: <383F62AA-096E-4D8E-BCE8-B2B87507C596@nrlssc.navy.mil>
URL: https://gitlist.dev/e/383F62AA-096E-4D8E-BCE8-B2B87507C596%40nrlssc.navy.mil
In-Reply-To: <20071123194904.GL2261MdfPADPa@greensroom.kotnet.org>

```

On Nov 23, 2007, at 1:49 PM, Sven Verdoolaege wrote:

> You didn't commit the change to mod_B to proj_one.
> Furthermore, you didn't push your changes to mod_B to
> the repo you specified for mod_B in .gitmodules.

Thanks for the help.

It works with the changes below.

Paul

I changed the creation of mod_b under mod_B to:

#  add mod_b to mod_B and push the changes back to mod_B

cd $GITDIR/proj_one/mod_B
git submodule add $GITDIR/modules/mod_b
git commit -m 'add module mod_b under module mod_B for project proj_one'
git push

cd $GITDIR/proj_one
git add mod_B
git commit -m 'reflect module mod_B update for project proj_one'
git status

and when I cloned it to:

#  clone the proj_one project (user user_a)

mkdir -p $GITDIR/user_a
cd $GITDIR/user_a
git clone $GITDIR/proj_one
cd $GITDIR/user_a/proj_one

#  get mod_A and mod_B

git submodule init
git submodule update

#  now get mod_b in mod_B

cd mod_B
git submodule init
git submodule update

```
