Search

Enter a search word or two and press return to see the search results.

Who am I?

Hi, I’m Graeme and these are my notes, from my messy desk. I started this blog because Google proved to be more useful at finding content than anything else I’ve used.

So I started adding my own content in the hopes that Google would index it and allow me to find things again in the future.

It works.

You can find out more about me here, and you should follow me on Twitter here.

Keeping up

You can automatically receive new content here by subscribing to the “Blog RSS” (link below). This is the easiest way to keep up with what I write here.  See this BBC article for a good introduction on RSS and keeping up with the goings on of the Internet more easily.

« Using git submodules to track vendor/rails | Main | Timestamps that can behave like booleans »
Thursday
10Apr2008

Read-only clones and committing changes to submodules

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.

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments (1)

I found had to create a tracking branch as well. That way you can work in the local branch writeable, and simply push to the writeable remote.

cd vendor/plugins/timestamped_booleans/
git remote add writable git@github.com:rubaidh/timestamped_booleans.git
git fetch writeable
git branch --track writeable writeable/master
git checkout writeable

make edits

git add ...
git commit ...
git push

October 15, 2008 | Unregistered CommenterTheo

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>