Syncing with Multiple Git Repos

This is almost entirely so that I remember how to do this. A big thanks for arcanez for showing me this in the first place.

The Problem

In the Perl community, numerous important git repositories are hosted at shadowcat, but of course if you went to that url you would not be able to see all the work that I have spent on each of those projects. I like the fact that github has a nice concise view of my work.

The Solution

The following is an example of a section from my .git/config in my DBIx-Class-DeploymentHandler:

[remote "all"]
   url = [email protected]:DBIx-Class-DeploymentHandler.git
   url = [email protected]:frioux/DBIx-Class-DeploymentHandler.git
[remote "origin"]
   fetch = +refs/heads/*:refs/remotes/origin/*
   url = [email protected]:DBIx-Class-DeploymentHandler.git
[remote "github"]
   fetch = +refs/heads/*:refs/remotes/github/*
   url = [email protected]:frioux/DBIx-Class-DeploymentHandler.git

This lets you push to origin, github, or all. I tend to only pull from origin and push to all. Hopefully this can at least be a reference for people :-)

(The following includes affiliate links.)

If you’re interested in learning more about Git, I cannot recommend Pro Git enough. It’s an excellent book that will explain how to use Git day-to-day, how to do more unusual things like set up Git hosting, and underlying data structures that will make the model that is Git make more sense.

Posted Sun, May 23, 2010

If you're interested in being notified when new posts are published, you can subscribe here; you'll get an email once a week at the most.