Hopefully this will be a shorter article, but I thought I’d get the tip into Google before I forget it and have to Google for the answer. :-)

Imagine the situation. You’re using Git submodules to manage your external dependencies, for example Rails plugins. Since not everybody on the project has push access to some of the plugins, naturally you’re using the public clone URL as the submodule URL for your project:

mathie@tullibardine:books$ git submodule add git://github.com/rubaidh/timestamped_booleans vendor/plugins/timestamped_booleans
Initialized empty Git repository in /Users/mathie/tmp/src/books/vendor/plugins/timestamped_booleans/.git/
[ ... ]

While some of the rest of your team don’t have push access to that particular repository, you do. While you’re working away, you happen to make a change to the submodule and commit it locally. Being a good submodule user, you know you must push those changes before you push the main repository, otherwise your coworkers will be stuck with a repository that references a tree that doesn’t yet exist in a repository they have access to. This is git speak for “the end of the world”.

So, how do we push those changes out when we’ve pulled from the read-only view of the repository? Well, we add another remote:

mathie@tullibardine:books$ cd vendor/plugins/timestamped_booleans/
mathie@tullibardine:timestamped_booleans$ git remote add writable git@github.com:rubaidh/timestamped_booleans.git
mathie@tullibardine:timestamped_booleans$ git push writable master
[ ... ]

Sorted. The changes are now committed for that submodule and we can happily push our other changes to the main repository too.

A Sneak Peek at
The Internet

If you enjoyed this article, you might be interested in my new project, A Sneak Peek at The Internet. What happens when you enter www.facebook.com into your web browser and hit return? A Sneak Peek at The Internet will take you on a deep dive through the network stack, from HTTP, SSL, TCP and IP, all the way down through the data link layer, back up to Facebook's data centres, and then on the return journey back to the browser.

There's more fun, excitement and peril than a Disneyland rollercoaster!