A Fresh Cup is Mike Gunderloy's software development weblog, covering Ruby on Rails and whatever else I find interesting in the universe of software. I'm a full-time Rails developer and contributor, available for long- or short-term consulting, with solid experience in working as part of a distributed team. If you'd like to hire me, drop me a line. I'm also the author of Rails Rescue Handbook and Rails Freelancing Handbook.

Navigation
« Double Shot #544 | Main | Double Shot #543 »
Saturday
Sep192009

Push to Multiple Git Repos

If you've got a project with multiple git remotes, and you'd like to update both of them with a single operation, there's an easy way to do it. Just edit your .git/config file to include a new target named "all":

[sourcecode language='ruby']
[remote "origin"]
url = git@github.com:ffmike/BigOldRailsTemplate.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[remote "codaset"]
url = git@codaset.com:ffmike/bigoldrailstemplate.git
fetch = +refs/heads/*:refs/remotes/codaset/*
[remote "all"]
url = git@github.com:ffmike/BigOldRailsTemplate.git
url = git@codaset.com:ffmike/bigoldrailstemplate.git
[/sourcecode]

With this setup, pushes and pulls on my local master branch go to GitHub by default. But if I execute 'git push all' it updates both the GitHub repository and the Codaset repository. The one little annoyance is that master then thinks it's ahead of the remote, but that's easily remedied by executing a 'git pull' on it.

I've been using this in cases where I'm backing up a repo to a private Gitosis server as well as spreading public repos between multiple cloud services for easy backup.

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.
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>