{"thread":{"id":"31897","subject":"Git submodule for a local branch?","startedAt":"2012-10-22T12:37:14Z","lastAt":"2012-10-23T22:09:55Z","messageCount":4,"participants":["W. Trevor King","Jens Lehmann"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"201690","messageId":"20121022123714.GL25563@odin.tremily.us","threadId":"31897","inReplyTo":null,"subject":"Git submodule for a local branch?","fromName":"W. Trevor King","fromEmail":"wking@tremily.us","sentAt":"2012-10-22T12:37:14Z","receivedAt":"2012-10-22T12:37:14Z","isPatch":false,"sender":{"key":"wking@tremily.us","avatar":"https://avatars.githubusercontent.com/u/209920?v=4"},"body":"I have a bunch of branches in my repo (a, b, c, …), and I'd like to\ncheck them out into subdirectories of another branch (index).  My\ninitial inclination was to use something like\n\n  $ git checkout index\n  $ git branch\n    a\n    b\n    c\n  * index\n  $ git submodule add -b a --reference ./ ./ dir-for-a/\n  $ git submodule add -b b --reference ./ ./ dir-for-b/\n  $ git submodule add -b c --reference ./ ./ dir-for-c/\n\nbut cloning a remote repository (vs. checking out a local branch)\nseems to be baked into the submodule implementation.  Should I be\nthinking about generalizing git-submodule.sh, or am I looking under\nthe wrong rock?  My ideal syntax would be something like\n\n  $ git submodule add -b c --local dir-for-c/\n\nThe motivation is that I have website that contains a bunch of\nsub-sites, and the sub-sites share content.  I have per-sub-site\nbranches (a, b, c) and want a master branch (index) that aggregates\nthem.  Perhaps this is too much to wedge into a single repository?\n\nCheers,\nTrevor\n\n-- \nThis email may be signed or encrypted with GnuPG (http://www.gnupg.org).\nFor more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy\n"},{"id":"201733","messageId":"20121023132111.GA26134@odin.tremily.us","threadId":"31897","inReplyTo":"20121022123714.GL25563@odin.tremily.us","subject":"Re: Git submodule for a local branch?","fromName":"W. Trevor King","fromEmail":"wking@tremily.us","sentAt":"2012-10-23T13:21:11Z","receivedAt":"2012-10-23T13:21:11Z","isPatch":false,"sender":{"key":"wking@tremily.us","avatar":"https://avatars.githubusercontent.com/u/209920?v=4"},"body":"On Mon, Oct 22, 2012 at 08:37:14AM -0400, W. Trevor King wrote:\n> but cloning a remote repository (vs. checking out a local branch)\n> seems to be baked into the submodule implementation.\n\nPerhaps --local would set submodule.$name.url to '.', and ome\ncombination of GIT_WORK_TREE, GIT_DIR, and object references could be\nused to setup and manage the local submodule.\n\n-- \nThis email may be signed or encrypted with GnuPG (http://www.gnupg.org).\nFor more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy\n"},{"id":"201754","messageId":"508704D5.9020902@web.de","threadId":"31897","inReplyTo":"20121022123714.GL25563@odin.tremily.us","subject":"Re: Git submodule for a local branch?","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2012-10-23T20:57:57Z","receivedAt":"2012-10-23T20:57:57Z","isPatch":false,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 22.10.2012 14:37, schrieb W. Trevor King:\n> I have a bunch of branches in my repo (a, b, c, …), and I'd like to\n> check them out into subdirectories of another branch (index).  My\n> initial inclination was to use something like\n> \n>   $ git checkout index\n>   $ git branch\n>     a\n>     b\n>     c\n>   * index\n>   $ git submodule add -b a --reference ./ ./ dir-for-a/\n>   $ git submodule add -b b --reference ./ ./ dir-for-b/\n>   $ git submodule add -b c --reference ./ ./ dir-for-c/\n> \n> but cloning a remote repository (vs. checking out a local branch)\n> seems to be baked into the submodule implementation.  Should I be\n> thinking about generalizing git-submodule.sh, or am I looking under\n> the wrong rock?  My ideal syntax would be something like\n> \n>   $ git submodule add -b c --local dir-for-c/\n\nBut then we'd have to be able to have two (or more) work trees using\nthe same git directory, which current submodule code can't.\n\n> The motivation is that I have website that contains a bunch of\n> sub-sites, and the sub-sites share content.  I have per-sub-site\n> branches (a, b, c) and want a master branch (index) that aggregates\n> them.  Perhaps this is too much to wedge into a single repository?\n\nTo me this sounds upside-down. I'd put the three sub-sites into\ndifferent repositories and the shared content into a submodule that\nall three sub-sites use. At least that is how I do all my content\nsharing on the websites I have done ... does that make sense?\n"},{"id":"201777","messageId":"20121023220955.GA30442@odin.tremily.us","threadId":"31897","inReplyTo":"508704D5.9020902@web.de","subject":"Re: Git submodule for a local branch?","fromName":"W. Trevor King","fromEmail":"wking@tremily.us","sentAt":"2012-10-23T22:09:55Z","receivedAt":"2012-10-23T22:09:55Z","isPatch":false,"sender":{"key":"wking@tremily.us","avatar":"https://avatars.githubusercontent.com/u/209920?v=4"},"body":"On Tue, Oct 23, 2012 at 10:57:57PM +0200, Jens Lehmann wrote:\n> Am 22.10.2012 14:37, schrieb W. Trevor King:\n> > but cloning a remote repository (vs. checking out a local branch)\n> > seems to be baked into the submodule implementation.  Should I be\n> > thinking about generalizing git-submodule.sh, or am I looking under\n> > the wrong rock?  My ideal syntax would be something like\n> > \n> >   $ git submodule add -b c --local dir-for-c/\n> \n> But then we'd have to be able to have two (or more) work trees using\n> the same git directory, which current submodule code can't.\n\nAnd that's the problem I'm trying to solve ;).\n\n> > The motivation is that I have website that contains a bunch of\n> > sub-sites, and the sub-sites share content.  I have per-sub-site\n> > branches (a, b, c) and want a master branch (index) that aggregates\n> > them.  Perhaps this is too much to wedge into a single repository?\n> \n> To me this sounds upside-down. I'd put the three sub-sites into\n> different repositories and the shared content into a submodule that\n> all three sub-sites use. At least that is how I do all my content\n> sharing on the websites I have done ... does that make sense?\n\nThat makes sense, however the problem is not in the common content, it\nis in the final index:\n\n  index\n  |-- sub-site a (branch of sub-site-x)\n  |-- sub-site b (branch of sub-site-x)\n  `-- sub-site c (branch of sub-site-x)\n\nAll of the sub-sites are branches of a single sub-site-x master:\n\n  o--o--o--o   sub-site-x\n   \\--o--o--o  sub-site-1\n       \\--o    sub-site-2\n        \\--o   sub-site-3\n\nSo they all live in the same repository.  My index repository will\nhave submodules for each of the sub-sites, and I'd like the index\nbranch to *also* live in same repository as the subsites.  This last\nbit is the sticky part.\n\nFor a proof-of-concept example (where I currently use public\nrepositories for the sub-site submodules), see\n\n  http://wking.github.com/swc-workshop/\n\nwhich uses gh-pages as the index branch, and master, 2012-10-caltech,\nand 2012-10-lbl for the sub-site branches.\n\n-- \nThis email may be signed or encrypted with GnuPG (http://www.gnupg.org).\nFor more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy\n"}]}