# Git-submodule questions

3 messages from 2007-10-19 to 2007-10-19. Participants: Evan Carroll, Linus Torvalds.
Thread: https://gitlist.dev/t/10383

## Evan Carroll, 2007-10-19 20:54

Subject: Git-submodule questions
Message-ID: <428b865e0710191354v59f558bbv4536d60902977ac@mail.gmail.com>
URL: https://gitlist.dev/e/428b865e0710191354v59f558bbv4536d60902977ac%40mail.gmail.com

```
I've got a set of 5 git repositories on one computer. I'm looking for
a way to more cleanly distribute them, and keep them in sync when i
distribute them. I'm trying to discern whether the scantly documented
git-submodule can accomplish this...

All of my git modules are in one place, /srv/DM: /srv/DM/a ..
/srv/DM/e to add them all into one super repository for easier
distributing I have to move them all to /srv/DM/git-old, then git init
in /srv/DM, then I git submodule add all of the modules in
/srv/DM/git-old. The question then comes down to why do I need to have
my git-submodules in /srv/DM, and /srv/DM/git-old.

Can I make a superproject out of /srv/DM and just some how add all of
that directories contents as submodules. When I try to add them as
like that I just get submodule 'a' already exists (because it does as
a non-submodule but as a git-repos.)

Picture a svn repository, now chop of the root, that's how my git
looks, and I'm trying to amend that. In svn all of your companies
projects can be tracked by one svn repository, not so in git. I'm
wondering if submodule is or isn't the tool to deliver this
functionality.

-- 
Evan Carroll
System Lord of the Internets
me@evancarroll.com
832-445-8877

```

## Linus Torvalds, 2007-10-19 21:22

Subject: Re: Git-submodule questions
Message-ID: <alpine.LFD.0.999.0710191420410.26902@woody.linux-foundation.org>
URL: https://gitlist.dev/e/alpine.LFD.0.999.0710191420410.26902%40woody.linux-foundation.org
In-Reply-To: <428b865e0710191354v59f558bbv4536d60902977ac@mail.gmail.com>

```


On Fri, 19 Oct 2007, Evan Carroll wrote:
>
> I've got a set of 5 git repositories on one computer. I'm looking for
> a way to more cleanly distribute them, and keep them in sync when i
> distribute them. I'm trying to discern whether the scantly documented
> git-submodule can accomplish this...

Sounds like subprojects are indeed a good way for you.

> All of my git modules are in one place, /srv/DM: /srv/DM/a ..
> /srv/DM/e to add them all into one super repository for easier
> distributing I have to move them all to /srv/DM/git-old, then git init
> in /srv/DM, then I git submodule add all of the modules in
> /srv/DM/git-old. The question then comes down to why do I need to have
> my git-submodules in /srv/DM, and /srv/DM/git-old.

You shouldn't need to do anything even half-way complicated like that.

In fact, it should be enough to do

	cd /srv/DM
	git init
	git add .
	git commit

and you're now literally all done!

		Linus

```

## Linus Torvalds, 2007-10-19 21:30

Subject: Re: Git-submodule questions
Message-ID: <alpine.LFD.0.999.0710191423130.26902@woody.linux-foundation.org>
URL: https://gitlist.dev/e/alpine.LFD.0.999.0710191423130.26902%40woody.linux-foundation.org
In-Reply-To: <alpine.LFD.0.999.0710191420410.26902@woody.linux-foundation.org>

```


On Fri, 19 Oct 2007, Linus Torvalds wrote:
> 
> In fact, it should be enough to do
> 
> 	cd /srv/DM
> 	git init
> 	git add .
> 	git commit
> 
> and you're now literally all done!

.. btw, when I say that, I guess I'm lying a bit.

Yes, the above will actually generate a valid git superproject repository, 
but it won't generate/populate the necessary .gitmodules stuff. You'd need 
to add it by hand.

But yes, if you want to avoid doing that hand-editing, you should use the 
whole "git submodule add .." thing to clone the git repos you already have 
into a supermodule. But the .gitmodules thing really is pretty simple, you 
just do something like

	[submodule "x"]
		path = x
		url = official-url-of-x
	[submodule "y"]
		path = y
		url = official-url-of-y

and now you just do "git submodule init" and you should be all done 
(again, the "git submodule init" thing you could do by hand by editing 
the .git/config file, but since you can do it automatically in-place, 
there's no real point).

		Linus

```
