{"thread":{"id":"22677","subject":"Git Submodule Usage Pattern","startedAt":"2010-02-16T14:39:19Z","lastAt":"2010-02-16T20:38:36Z","messageCount":4,"participants":["Tim Visher","Avery Pennarun","Andreas Krey"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"134733","messageId":"c115fd3c1002160639m113a3604wa6686bc613a7c202@mail.gmail.com","threadId":"22677","inReplyTo":null,"subject":"Git Submodule Usage Pattern","fromName":"Tim Visher","fromEmail":"tim.visher@gmail.com","sentAt":"2010-02-16T14:39:19Z","receivedAt":"2010-02-16T14:39:19Z","isPatch":false,"sender":{"key":"tim.visher@gmail.com","avatar":"https://gravatar.com/avatar/98307ce54bcac1a46b5d845827d5386e2a27895ff08790cdd3877ad527760575?d=mp&s=160"},"body":"Hello Everyone,\n\nI recently found a case where I thought submodules would be a perfect\nfit.  I confess that I don't fully understand how submodules are\nsupposed to work.  The [section in the Pro Git\nBook](http://progit.org/book/ch6-6.html) is fairly explanatory but\nalso seems to be very cautionary.  The man page also is a little\ncryptic, sort of like submodules really aren't supposed to be used all\nthat often, which I think is indeed the community feeling.\n\nThat being said, I wanted to include the [zen-and-art color\ntheme](http://github.com/irfn/zen-and-art) in my .emacs file and since\nit is already a git repo, I figured that it's the perfect case for a\nsubmodule.  Now I ran into a problem.\n\nI have the following configuration typically.  My main box at home\nwill point at GitHub if I have a public repo, as I do with my .emacs\nfile.  I then also sync with 2 other locations, a Backup directory for\nsafety's sake and a USB stick.  The stick repo is so that I have a\nplace to sync to if I have to work behind a firewall, as I do at work.\n I want to not have to remember to sync to 2 places from home so that\nI can work at work and I don't feel like writing a script that would\nallow me to not have to remember it (although that is, admittedly, one\nsolution to my problem).  The solution I came up with was to have my\nwork repo clone via `http://` from GitHub (that would be `origin`) to\nget the latest changes I made at home, but then push to my Stick if I\nneeded to do any emergency work so that my home location could grab\nthose changes and then push them out to GitHub.  Obviously at home I\nwould just be pushing and pulling from GitHub.\n\nSo that's:\n\n                     GitHub\n                    /   ^ \\\n                   /   /   \\\n                  /   /     \\\n              --git://--     \\\n                /   /       http://\n               /   /           \\\n              /   /      ---firewall---\n             /   /               \\\n            v   /                 v\n           Home Box              Work\n         /       ^ \\              /\n   file system  file system      /\n       /           \\ \\          /\n      v             \\ v        v\n    Backup          ----Stick----\n\n---aside---\nFor those of you reading mail in a sucky reader like GMail (as I am)\nthat ASCII art got pretty well screwed.\n\nI posted a picture of it\n[here](http://random.burningones.com/gitSubmodulesWorkflow.png).\n\nSorry…\n---aside--\n\nThis works great because remotes are configured on a per-repo basis.\nMy origin at work points where it needs to and my origin at home does\nthe same.  Now comes the confusion.\n\nApparently, submodules are not configured on a per-repo basis, unless\nI'm totally misunderstanding something.  The .gitmodules file wants to\nbe checked in just like .gitignore, etc.  I don't know if submodules\nwill work correctly without syncing that between repos, either.  What\nI need is to have the submodule at work point at a different repo than\nthe submodule at Home to avoid firewall issues.  Or for someone to\nsuggest a different work flow that would allow me to have my main home\nrepo point at GitHub using my private git:// address and the\nzen-and-art repo using it's public git:// clone address and then have\nmy Work repo clone from GitHub around the firewall (or somewhere else,\nGitHub's http cloning is still pretty Janky) but then push to the\nStick.\n\nThanks in advance for your thoughts.\n\n-- \n\nIn Christ,\n\nTimmy V.\n\nhttp://burningones.com/\nhttp://five.sentenc.es/ - Spend less time on e-mail\n"},{"id":"134763","messageId":"32541b131002160948h317e71f5m2d2cb839470a38f1@mail.gmail.com","threadId":"22677","inReplyTo":"c115fd3c1002160639m113a3604wa6686bc613a7c202@mail.gmail.com","subject":"Re: Git Submodule Usage Pattern","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2010-02-16T17:48:16Z","receivedAt":"2010-02-16T17:48:16Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On Tue, Feb 16, 2010 at 9:39 AM, Tim Visher <tim.visher@gmail.com> wrote:\n> Apparently, submodules are not configured on a per-repo basis, unless\n> I'm totally misunderstanding something.  The .gitmodules file wants to\n> be checked in just like .gitignore, etc.  I don't know if submodules\n> will work correctly without syncing that between repos, either.  What\n> I need is to have the submodule at work point at a different repo than\n> the submodule at Home to avoid firewall issues.  Or for someone to\n> suggest a different work flow that would allow me to have my main home\n> repo point at GitHub using my private git:// address and the\n> zen-and-art repo using it's public git:// clone address and then have\n> my Work repo clone from GitHub around the firewall (or somewhere else,\n> GitHub's http cloning is still pretty Janky) but then push to the\n> Stick.\n\nThree suggestions I can offer:\n\n1) After running 'git submodule init', look in .git/config.  You can\nchange which repos the submodules point to from there, on a per-repo\nbasis, and not affect other people's checkouts.\n\n2) Try using relative repo paths (like ../foo.git) in .gitmodules.\nThen as long as your repositories are siblings of each other, if you\ncan check out one you can check out the other.\n\n3) git-subtree (http://github.com/apenwarr/git-subtree) does not\nexhibit this problem.\n\nHave fun,\n\nAvery\n"},{"id":"134782","messageId":"20100216200035.GA19834@inner.home.ulmdo.de","threadId":"22677","inReplyTo":"32541b131002160948h317e71f5m2d2cb839470a38f1@mail.gmail.com","subject":"Re: Git Submodule Usage Pattern","fromName":"Andreas Krey","fromEmail":"a.krey@gmx.de","sentAt":"2010-02-16T20:00:35Z","receivedAt":"2010-02-16T20:00:35Z","isPatch":false,"sender":{"key":"a.krey@gmx.de","avatar":"https://avatars.githubusercontent.com/u/37810?v=4"},"body":"On Tue, 16 Feb 2010 12:48:16 +0000, Avery Pennarun wrote:\n...\n> Three suggestions I can offer:\n...\n> 2) Try using relative repo paths (like ../foo.git) in .gitmodules.\n\nIs that a 'try', or are those supposed to work?\n\n4) Use\n\n  [url \"git@github.com:apk/\"]\n      insteadOf = \"git://github.com/apk/\"\n\nin ~/.gitconfig allows changing the the actual url used. I use that\nto be able to clone seemingly with the public github url but still\nbe able to push. You can use that to let an submodule point to\nsome other place where there is a clone of the submodule repo,\nor another access method.\n\nAndreas\n"},{"id":"134786","messageId":"32541b131002161238h5549882fv89ab90812b3e8131@mail.gmail.com","threadId":"22677","inReplyTo":"20100216200035.GA19834@inner.home.ulmdo.de","subject":"Re: Git Submodule Usage Pattern","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2010-02-16T20:38:36Z","receivedAt":"2010-02-16T20:38:36Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On Tue, Feb 16, 2010 at 3:00 PM, Andreas Krey <a.krey@gmx.de> wrote:\n> On Tue, 16 Feb 2010 12:48:16 +0000, Avery Pennarun wrote:\n>> Three suggestions I can offer:\n> ...\n>> 2) Try using relative repo paths (like ../foo.git) in .gitmodules.\n>\n> Is that a 'try', or are those supposed to work?\n\nIt works.  The reason I said \"try\" is that in order to *make* it work,\nyou may have to move your repositories around so that you can reach\none using a relative path from the other (ie. it's easiest if they're\non the same server at the same level of the directory hierarchy).\n\nAvery\n"}]}