Push to Multiple Git Repos (Posted on December 22nd, 2012)
Here's a cool little trick I found out about the other day. Even though Git is a distributed revision control system, there are times when you need to push to two systems at once. In my case those systems are Github and Heroku. Here is a simple way to do it by modifying your .git/config file.
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "heroku"] url = [email protected]:maxburstein.git fetch = +refs/heads/*:refs/remotes/heroku/* [remote "github"] url = [email protected]:mburst/burstolio.git fetch = +refs/heads/*:refs/remotes/github/* [remote "origin"] url = [email protected]:maxburstein.git url = [email protected]:mburst/burstolio.git
The "heroku" and "github" remotes are generated by git and are created in the setup instructional steps of each service respectively. I went ahead and manually added the remote "origin" and just copied the url variable from the other remotes. You'll now be able to push to both by calling "git push origin" and then you can fetch from each one as individually needed.
Tags: Git
About Me
My name is Max Burstein and I am a graduate of the University of Central Florida and creator of Problem of the Day and Live Dota. I enjoy developing large, scalable web applications and I seek to change the world.