git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Git Submodule Usage Pattern

From
Tim Visher <tim.visher@gmail.com>
Date
Feb 16, 2010, 14:39 UTC
Message-ID
<c115fd3c1002160639m113a3604wa6686bc613a7c202@mail.gmail.com>
Hello Everyone,

I recently found a case where I thought submodules would be a perfect fit. I confess that I don't fully understand how submodules are supposed to work. The [section in the Pro Git Book](http://progit.org/book/ch6-6.html) is fairly explanatory but also seems to be very cautionary. The man page also is a little cryptic, sort of like submodules really aren't supposed to be used all that often, which I think is indeed the community feeling.

That being said, I wanted to include the [zen-and-art color theme](http://github.com/irfn/zen-and-art) in my .emacs file and since it is already a git repo, I figured that it's the perfect case for a submodule. Now I ran into a problem.

I have the following configuration typically.  My main box at home
will point at GitHub if I have a public repo, as I do with my .emacs
file.  I then also sync with 2 other locations, a Backup directory for
safety's sake and a USB stick.  The stick repo is so that I have a
place to sync to if I have to work behind a firewall, as I do at work.
 I want to not have to remember to sync to 2 places from home so that
I can work at work and I don't feel like writing a script that would
allow me to not have to remember it (although that is, admittedly, one
solution to my problem).  The solution I came up with was to have my
work repo clone via `http://` from GitHub (that would be `origin`) to
get the latest changes I made at home, but then push to my Stick if I
needed to do any emergency work so that my home location could grab
those changes and then push them out to GitHub.  Obviously at home I
would just be pushing and pulling from GitHub.
So that's:
                     GitHub
                    /   ^ \
                   /   /   \
                  /   /     \
              --git://--     \
                /   /       http://
               /   /           \
              /   /      ---firewall---
             /   /               \
            v   /                 v
           Home Box              Work
         /       ^ \              /
   file system  file system      /
       /           \ \          /
      v             \ v        v
    Backup          ----Stick----

---aside--- For those of you reading mail in a sucky reader like GMail (as I am) that ASCII art got pretty well screwed.

I posted a picture of it [here](http://random.burningones.com/gitSubmodulesWorkflow.png).

Sorry… ---aside--

This works great because remotes are configured on a per-repo basis. My origin at work points where it needs to and my origin at home does the same. Now comes the confusion.

Apparently, submodules are not configured on a per-repo basis, unless I'm totally misunderstanding something. The .gitmodules file wants to be checked in just like .gitignore, etc. I don't know if submodules will work correctly without syncing that between repos, either. What I need is to have the submodule at work point at a different repo than the submodule at Home to avoid firewall issues. Or for someone to suggest a different work flow that would allow me to have my main home repo point at GitHub using my private git:// address and the zen-and-art repo using it's public git:// clone address and then have my Work repo clone from GitHub around the firewall (or somewhere else, GitHub's http cloning is still pretty Janky) but then push to the Stick.

Thanks in advance for your thoughts.
-- 
In Christ,

Timmy V.

http://burningones.com/
http://five.sentenc.es/ - Spend less time on e-mail
Next: Avery Pennarun
Message 1 of 4 in “Git Submodule Usage Pattern”
  1. Tim VisherFeb 16, 2010
  2. Avery PennarunFeb 16, 2010
  3. Andreas KreyFeb 16, 2010
  4. Avery PennarunFeb 16, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.