Automatically pulling into a committer's Git repository

I was a bit unhappy because I couldn't keep my "bare" Git repository up-to-date unattended — I needed to be at my workstation to be able to do a git fetch, because it needs my SSH passphrase.

I didn't have this problem with CVS because I kept an rsync copy of the anonymous CVS repository, from which my regular trees where checked out. (My committer's checkouts were separate, which was annoying, but I considered that problem solved with the jump to Git.)

Yesterday I had an epiphany that this could be solved very easily: just add a new remote to the anonymous clone, which doesn't require any SSH key to be involved, and so can run unattended. This sounds quite trivial, but I couldn't make it work at first for reasons that appeared quite obscure; and indeed they were :-)

The full solution looks like this:

git remote add anon-origin git://git.postgresql.org/git/postgresql.git

This adds the new remote, from which you can "git fetch anon-origin"; but while it will pick up the objects when you do, it won't update the branches. To make it update the branches, you have to fetch into each branch explicitely:

git fetch anon-origin \
    master:master REL9_0_STABLE:REL9_0_STABLE \
    REL8_4_STABLE:REL8_4_STABLE REL8_3_STABLE:REL8_3_STABLE \
    REL8_2_STABLE:REL8_2_STABLE

Now I can have this in my crontab and be confident that the repository will be always reasonably up to date.

Why this doesn't work without this trick is beyond me, but I don't really care all that much. I'm not into Git internals enough, it seems (and I don't think I want to be anyway).

Of course, non-committers don't have this problem, because they can always run "git fetch" or "git pull" without worrying about being asked for a passphrase.