threads / discuss / 14658

Submodules: Publishing a locally created submodule.

Subject: Submodules: Publishing a locally created submodule.

## tl;dr

4 messages between Jul 24, 2008 and Jul 25, 2008.

replies: 3people: 3as markdown or json

Thomas Adam· Jul 24, 2008, 15:40 UTC · lore
Hello all,

I'm a little confused having read the submodule chapter in the GIT users' manual and was wondering if someone here can help.

I've setup a bare repository with some submodule in it which I and others are able to clone from just fine -- in that sense, it acts just like an "ordinary" repository.

But I am a little stuck getting my head around a scenario:
Most us here work in a very CVS-like way.  I did the following:

git clone ssh://foo/bar/project myclone cd ./myclone

In there is a directory which is a submodule.  At the time I created
the bare repo it was cloned already from a repo which had a submodule.
 I decided I wanted another submodule to be published so I did this:
cp -r ./mysubmoduleA ./mysubmoduleB && rm ./mysubmoduleB/.git
Now:  I want to make mysubmoduleB a submodule which I can publish to
the shared repository and when others pull, to see that submodule and
be able to treat it as such.
But I can't see how to do that.  Can someone help?
Many thanks in advance.
-- Thomas Adam
Sean Estabrooks· Jul 24, 2008, 16:21 UTC · re: Thomas Adam · lore

Re: Submodules: Publishing a locally created submodule.

On Thu, 24 Jul 2008 16:40:43 +0100 "Thomas Adam" <thomas.adam22@gmail.com> wrote:

> Now:  I want to make mysubmoduleB a submodule which I can publish to
> the shared repository and when others pull, to see that submodule and
> be able to treat it as such.
Hi Thomas,

Submodules are very much fully formed independent repositories. So the first step is to create a new Git repo that holds the files you want. Publish this repo in a public place, presumably the same place you published your other submodules.

In your supermodule use "git submodule add" to include the new public repo as a submodule in the directory of your choice. After which you can commit the change and push it out. Other people will need to do "git submodule update" to make their repos aware of the new submodule.

HTH, Sean

Mark Levedahl· Jul 24, 2008, 23:30 UTC · re: Thomas Adam · lore

Re: Submodules: Publishing a locally created submodule.

Thomas Adam wrote:
Show 12 quoted lines
> Hello all,
> 
> 
> Now:  I want to make mysubmoduleB a submodule which I can publish to
> the shared repository and when others pull, to see that submodule and
> be able to treat it as such.
> 
> But I can't see how to do that.  Can someone help?
> 
> Many thanks in advance.
> 
> -- Thomas Adam
git submodule add <URL where this will exist> ./mysubmoduleB

will recognize that mysubmoduleB is already a valid git repo and add it as is at the current location to the superproject.

Mark
Thomas Adam· Jul 25, 2008, 00:05 UTC · re: Mark Levedahl · lore

Re: Submodules: Publishing a locally created submodule.

Hello --
2008/7/25 Mark Levedahl <mlevedahl@gmail.com>:
> git submodule add <URL where this will exist> ./mysubmoduleB
>
> will recognize that mysubmoduleB is already a valid git repo and add it as
> is at the current location to the superproject.

Ah -- now that was missing from the documentation (the syntax; not the intention.) Thanks.

It seems my brain has turned to mush so I need to go back to square one and verify the steps for this are accurate. If I am doing this arse-about-face, do say. ;)

I've mentioned I am using a bare repository which is shared amongst developers. We've been using one fine for normal development and for various reaons I am creating a new repository to be filled with submodules. I shall call this "SM".

Our "superproject" is a directory hierarchy with interspersed files. On the server I did this:

server% cd /usr/src/SM server% git init server% cd ./superproject server% git init server% git add . server% git commit -m "Initial checkin" server% cd .. server% git submodule add /path/to/usr/src/SM server% git commit -a -m "Submodules..."

Then cloned a bare repo from that which I was able to clone locally and do stuff in. I could push stuff out too for that one project. But how from this clone do I then publish any further submodules I might create locally? I can't very well do so directly in my checkout -- it has no concept of where the submodules are. I could go to the server, add another directory as a submodule (as I've done with "superproject" above --- but then any changes under /usr/src/SM on the server are local -- the bare repo has no knowledge of any changes made there.

Does this even make sense?   ;)
Thanks in advance.
-- Thomas Adam

← back to recent threads