threads / discuss / 25706

git remote vs. submodules

Subject: git remote vs. submodules

## tl;dr

5 messages between Nov 11, 2010 and Nov 11, 2010.

replies: 4people: 2as markdown or json

Patrick Doyle· Nov 11, 2010, 01:45 UTC · lore

Hello All, I was just reading about git remote and I started thinking to myself, "Gee, nothing I've read says that the remotes have to share a common ancestor. I wonder what would happen if I added two independent repositories as remotes to a superproject?"

So I tried it in a very trivial case. The first thing I learned was that I need to make the subprojects subdirectories of a top level .git-housing directory. Or else, when I merge them in, everything in the top level of subproject1 gets mixed in with everything in the top level of subproject2. So this doesn't seem to be a good solution for marrying arbitrary subprojects together. But if I set up a library of subprojects properly, it seems like I could do this.

So now I'm wondering... has anybody else ever had thoughts along these lines? Has anybody tried this? Has anybody seen it work (or fail miserably)?

Why would I want to do this instead of using submodules? I dunno. It just came to mind when I started trying to understand what's really going on with remotes. And I vaguely (and perhaps even correctly) recall there being some controversy regarding submodules when they were first introduced.

Anyway, I figured It wouldn't hurt to ask folks in the know.
--wpd
Tomas Carnecky· Nov 11, 2010, 11:34 UTC · re: Patrick Doyle · lore

Re: git remote vs. submodules

On 11/11/10 2:45 AM, Patrick Doyle wrote:
Show 23 quoted lines
> Hello All,
> I was just reading about git remote and I started thinking to myself,
> "Gee, nothing I've read says that the remotes have to share a common
> ancestor.  I wonder what would happen if I added two independent
> repositories as remotes to a superproject?"
> 
> So I tried it in a very trivial case.  The first thing I learned was
> that I need to make the subprojects subdirectories of a top level
> .git-housing directory.  Or else, when I merge them in, everything in
> the top level of subproject1 gets mixed in with everything in the top
> level of subproject2.  So this doesn't seem to be a good solution for
> marrying arbitrary subprojects together.  But if I set up a library of
> subprojects properly, it seems like I could do this.
> 
> So now I'm wondering... has anybody else ever had thoughts along these
> lines?  Has anybody tried this?  Has anybody seen it work (or fail
> miserably)?
> 
> Why would I want to do this instead of using submodules?  I dunno.  It
> just came to mind when I started trying to understand what's really
> going on with remotes.  And I vaguely (and perhaps even correctly)
> recall there being some controversy regarding submodules when they
> were first introduced.

Are you maybe looking for a subtree merge? http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html

tom
Patrick Doyle· Nov 11, 2010, 14:44 UTC · re: Tomas Carnecky · lore

Re: git remote vs. submodules

On Thu, Nov 11, 2010 at 6:34 AM, Tomas Carnecky <tom@dbservice.com> wrote:
> Are you maybe looking for a subtree merge?
> http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html

Yeah, that looks like it. I never would have hit upon the read-tree step by myself -- I would have just laid things out with the prefix already embedded in the subprojects.

Hmmm... it seems to me that feeding changes back to the subprojects might be difficult (and that is born out by a comment at the end of the page you referenced.)

How much do folks use this approach?
--wpd
Tomas Carnecky· Nov 11, 2010, 15:00 UTC · re: Patrick Doyle · lore

Re: git remote vs. submodules

On 11/11/10 3:44 PM, Patrick Doyle wrote:
Show 11 quoted lines
> On Thu, Nov 11, 2010 at 6:34 AM, Tomas Carnecky <tom@dbservice.com> wrote:
>> Are you maybe looking for a subtree merge?
>> http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html
> 
> Yeah, that looks like it.  I never would have hit upon the read-tree
> step by myself -- I would have just laid things out with the prefix
> already embedded in the subprojects.
> 
> Hmmm... it seems to me that feeding changes back to the subprojects
> might be difficult (and that is born out by a comment at the end of
> the page you referenced.)
https://github.com/apenwarr/git-subtree, it makes exactly that easier.
tom
Patrick Doyle· Nov 11, 2010, 15:11 UTC · re: Tomas Carnecky · lore

Re: git remote vs. submodules

On Thu, Nov 11, 2010 at 10:00 AM, Tomas Carnecky <tom@dbservice.com> wrote:
Show 14 quoted lines
> On 11/11/10 3:44 PM, Patrick Doyle wrote:
>> On Thu, Nov 11, 2010 at 6:34 AM, Tomas Carnecky <tom@dbservice.com> wrote:
>>> Are you maybe looking for a subtree merge?
>>> http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html
>>
>> Yeah, that looks like it.  I never would have hit upon the read-tree
>> step by myself -- I would have just laid things out with the prefix
>> already embedded in the subprojects.
>>
>> Hmmm... it seems to me that feeding changes back to the subprojects
>> might be difficult (and that is born out by a comment at the end of
>> the page you referenced.)
>
> https://github.com/apenwarr/git-subtree, it makes exactly that easier.
That looks cool too!  Thanks.
--wpd

← back to recent threads