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

Comments:

  • Lucas - 2 years, 5 months ago

    I "figured this out" recently. I stopped using it because pushing to "origin" won't update your remote head for "heroku" and "github". Having some semantic-client-side connections for this could be tricky, so I've just learned to avoid it. (But if you need to do multiple pushed often, and know enough about git to handle the caveats, this works well.)

    reply

  • nsf - 2 years, 5 months ago

    I just do this: [alias] pub = "!git push pubgit && git push github"

    reply

  • Gergely Polonkai - 2 years, 5 months ago

    Why modify the config directly if git can do it for you? $ git remote add heroku [email protected]:maxburstein.git $ git remote add github [email protected]:mburst/burstolio.git

    reply

  • Max Burstein - 2 years, 5 months ago

    That will work perfectly for setting up the heroku and github branch. However, for pushing to both of them I needed to add a 3rd branch manually that I called origin. If you try to git remote add a url to a branch that already exists it will throw back "fatal: remote heroku already exists". So to get around that I just went ahead and did it manually.

    reply

  • facebook - 3 weeks ago

    Thanks for sharing the post.. parents are worlds best person in each lives of individual..

    reply

  • simcitu buildit wiki - 2 weeks ago

    This is cool post and i enjoy to read this post. your blog is fantastic and you have good staff in your blog. nice sharing keep it up.

    reply

  • Free Minecraft Account 2015 - 1 week, 6 days ago

    I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work

    reply

  • code triche clash of clans - 1 week, 3 days ago

    Je aime votre poste et tout ce que vous partagez avec nous est uptodate et très instructif, je tiens à ajouter la page donc je peux revenir ici de vous lire, que vous avez fait un travail merveilleux

    reply

  • gameofwar.instantdownloadsz.com - 1 week, 1 day ago

    This post is truly inspiring. I like your post and everything you share with us is current and very informative.I'm ԁеfinitеly enϳoуіng youг blοg anԁ look forward to new uρdates.

    reply

  • acupuncture nyc - 1 week, 6 days ago

    I would also motivate just about every person to save this web page for any favorite assistance to assist posted the appearance.

    reply

  • cheap seo blogcomments service - 1 week, 4 days ago

    Your articles don't displace In regards to the bushes correct t towards part.More Bonuses

    reply

  • No credit check loans online - 1 day, 22 hours ago

    I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article.

    reply

  • education news - 1 month, 1 week ago

    Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include.

    reply

  • man and van - 2 days, 21 hours ago

    I read this article. I think You put a lot of effort to create this article. I appreciate your work.

    reply

  • hack hay day - 1 month ago

    The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.

    reply

  • marketing1on1.com - 2 weeks, 6 days ago

    Blessed I am that I am reading this blessed document these days. I really assumed that the very best of the articles stopped arriving. However immediately after looking over this, my belief rises again

    reply

  • affordable small business SEO services - 2 weeks, 5 days ago

    This is my first time i visit here and I found so many interesting stuff in your blog especially it's discussion, thank you.

    reply

  • power of attorney registration - 1 week, 5 days ago

    This blog has got lots of really helpful information on it! Cheers for sharing it with me!

    reply

  • Click for source - 3 days, 19 hours ago

    This is very educational content and written well for a change. It's nice to see that some people still understand how to write a quality post about ultrasound technician.

    reply

  • mybestwebhostingoffers.com - 1 week, 2 days ago

    Thanks for writing engaging and interesting material.Found this on MSN and I’m happy I did. Well written article.

    reply

  • turbulence training - 1 week, 2 days ago

    Do you mind updating your blog post with additional insight? It should be really useful for all of us.

    reply

  • visit this website - 1 week ago

    Thanks a lot for providing individuals with a spectacular possibility, I am always searching online for articles that can help me.

    reply

  • 8 ball pool cheat - 1 month ago

    Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.

    reply

  • walkfit in stores - 1 month ago

    Thank you so much for sharing this great blog.Very inspiring and helpful too.Hope you continue to share more of your ideas.I will definitely love to read.

    reply

  • buy facebook likes - 3 weeks, 2 days ago

    Very good points you wrote here..Great stuff...I think you've made some truly interesting points.Keep up the good work.

    reply

  • buy pinterest followers - 3 weeks, 2 days ago

    Great Information sharing .. I am very happy to read this article .. thanks for giving us go through info.Fantastic nice. I appreciate this post.

    reply

  • ville a monaco - 2 weeks, 2 days ago

    I really enjoyed reading this post, big fan. Keep up the good work andplease tell me when can you publish more articles or where can I read more on the subject?

    reply

  • specs - 1 week, 2 days ago

    Easily, the article is actually the best topic on this registry related issue. I fit in with your conclusions and will eagerly look forward to your next updates.

    reply

  • High School Diploma at Home - 1 week ago

    Good post you have shared here keep it up.

    reply