Content

Not quite a Yegge long.

Using Github with MsysGit

Saturday 19 December 2009 - Filed under Uncategorized

I’ve been happily using Git for all my personal projects for the last couple of months, and everything is great – except for the performance of Github for pulling and pushing. I’ll outline here the steps I took to fix it.

First, I noticed that only the authenticated access to Github is pathetically slow. Pulling from the public URI is fast. I tried exploiting this by adding a read-only copy of each remote:

$ git remote add origin-ro -f git://github.com/chrisforbes/OpenRA.git

Then I just use the appropriate remote for pulls and pushes:

$ git pull origin-ro master                 # grab upstream changes
$ git push origin master                    # push changes back

Now this works, but it has some undesirable side-effects. For example, one of my projects is fairly active, with others contributing to the upstream Github repo. This is normally fine, except that git doesn’t know the two remotes are actually the same repo (how could it?) so they get their heads out of sync. I find myself having to do this several times a day to get a sane view of upstream:

$ git fetch origin-ro

That’s not ideal, so I did a bit of digging around, and noticed interesting output from the git-remote command:

$ git remote –v
... snip ...
origin  git@github.com:chrisforbes/OpenRA.git (fetch)
origin  git@github.com:chrisforbes/OpenRA.git (push)

This seems to suggest that you can set different fetch & push URLs. Yet the git-remote manual page says nothing about this – in fact, it’s pretty clear that there are two config options that control this stuff. Unhelpful.

It turns out that if you read the git-push man page, or the git-config man page (which is useful, but incredibly long), there’s another option: remote.<remote-name>.pushurl. Time to fix this mess:

$ git config remote.origin.url git://github.com/chrisforbes/OpenRA.git
$ git config remote.origin.pushurl git@github.com:chrisforbes/OpenRA.git
$ git remote rm origin-ro

... repeat for every other remote i have ...

So we’ve switched the fetch URL over to use anonymous access, and set pushurl to something that allows writing. Because it’s all within the same remote now, git (esp gitk, which is very dumb!) doesn’t get confused.

Hopefully this is useful to someone :D

2009-12-19  »  admin

Share your thoughts

Re: Using Github with MsysGit







Tags you can use (optional):
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>