How to push to multiple remote Git repositories using 1 Eclipse operation (killing 2 birds with 1 stone)

October 16, 2013 Appirio


By Enda Traynor

I recently spent some time trying to figure out this very issue and so thought it would be useful to share what I learned.

Consider this scenario for a moment: you have your local Git repository which you diligently commit to throughout the day. Once you are happy with your latest version, you push your new release to Heroku. What if you also wanted to share the same set of code to a friend you collaborate with on Bitbucket? Wouldn’t it be nice to run one operation in Eclipse which deploys to Heroku and pushes to your Bitbucket repository?

Here is is how to do just that:

Firstly, lets create a completely new application using the Heroku plugin in Eclipse.

  1. File -> New -> Other -> Heroku -> “Create Heroku App from Template”

  1. Pick an application template (I picked the connected Java app with Spring,Oauth) from the options and click Finish. Note that if you don’t provide a name, Heroku will come up with one for you.

  1. Your application will now be created in Heroku with the local version residing on your machine. If you have eGit setup successfully, your local git repository should all be setup as well.

  1. If we change to the Git Repository Exploring perspective (Window -> Open Perspective -> Other -> Git Repository Exploring), we can see the repository information.

  1. By expanding the Remotes option, we can see the heroku remote repository details.

  1. This is where we need to add our information about other remote repositories we wish to push to by right-clicking on the heroku location and selecting Configure Push

  2. Once there, we can add the remote repositories we wish to push to, by selecting the Add button in the Push URIs section.

  1. Once you have added the detail of your other remote repository, like I have above, you can hit the Finish button. This will bring you back to the Configure Push dialog where you must also enter the original heroku git remote details as an additional add like below.

  1. This is done so that the Push knows it needs to go to both locations. See below for how the Configure Push dialog will look with both Push URIs selected. Hit Save to exit out of the Configure Push dialog.

  1. Note that the Fetch operation will still be set to pull from Heroku as a Fetch operation can obviously only pull from one location. This can easily be changed to be the BitBucket repository if necessary by right-clicking on the fetch operation and selecting Configure Fetch. 

  1. Now that you have the configuration setup as you wish, you can push to Heroku and BitBucket with one operation, Right-click -> Team -> Push to Upstream:

  1. When you see the following dialog, you can see that the push successfully went to both locations

Configuration Note:

This blog post assumes you are running Eclipse Indigo (3.7) as this the only Eclipse version I have found that seems to work seamlessly with the plugin, eGit and the Heroku Eclipse plugin.


Here are some useful blog posts I used when setting up my Eclipse configuration:

Previous Article
Cloud Assets – Build it Better, Stronger, Faster
Cloud Assets – Build it Better, Stronger, Faster

This is the first blog post in an ongoing series in which we’ll highlight our Cloud Assets.  At Appirio we’...

Next Article
Salesforce Admin Hack Series: Account Object
Salesforce Admin Hack Series: Account Object

Just recently I had the privilege of co-hosting a webinar with Michael Farrington of RingLead (Shout out to...