threads / discuss / 10383

Git-submodule questions

Subject: Git-submodule questions

## tl;dr

3 messages between Oct 19, 2007 and Oct 19, 2007.

replies: 2people: 2as markdown or json

Evan Carroll· Oct 19, 2007, 20:54 UTC · lore

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· Oct 19, 2007, 21:22 UTC · re: Evan Carroll · lore

Re: Git-submodule questions

On Fri, 19 Oct 2007, Evan Carroll wrote:
Show 5 quoted lines
>
> 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.
Show 6 quoted lines
> 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· Oct 19, 2007, 21:30 UTC · re: Linus Torvalds · lore

Re: Git-submodule questions

On Fri, 19 Oct 2007, Linus Torvalds wrote:
Show 9 quoted lines
> 
> 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

← back to recent threads