35

I have two computers and I want both of them to be able to pull/push from the same repo on github as well as deploy to the same app on heroku. I know that Heroku allows you to clone its git repo on another computer so it can be linked up too, but I don't want the second to clone the heroku repo - i want it to clone the git repo and then have both computers be able to update heroku when either one deploys... how do I do this? Already the two are connected to the same github successfully but I now want to connect them to the same heroku app.

Kvass
  • 8,294
  • 12
  • 65
  • 108

4 Answers4

51

git remote add heroku git@heroku.com:your_app_name.git

sybohy
  • 1,856
  • 2
  • 20
  • 25
  • 2
    Worked for me as well, thanks. One quick clarification - the 'project.git' portion of the command is the heroku app name, not the github repo name. – Blake Feb 09 '13 at 05:56
  • 4
    Remember to run `heroku keys:add` on the second machine, before trying to push to Heroku. – Alexander Popov Aug 21 '13 at 07:17
  • 1
    If you don't know what your app name is use `heroku list` after logging in to Heroku to find out. – Toby 1 Kenobi Oct 06 '15 at 23:16
3
  1. Clone your app from Github on all your computers.
  2. Use ONE computer to git push heroku.
  3. All other computers add Heroku as a remote.

So do this to all your computers where you want heroku commands:

git remote add heroku git@heroku.com:project.git

And the you can push to both Git and Heroku at the same time with these configurations:

git remote add all github:path/proj.git
git remote set-url --add --push all url = heroku:path/proj.git

Then git push heroku will push to all.

thenengah
  • 42,557
  • 33
  • 113
  • 157
1

Building on the answers above, but updating as the Heroku dashboard appears to have changed:

  1. Select your app
  2. Select Settings
  3. Under info, find Git URL and use that (e.g., git@heroku.com:your-app_name-xxxx.git, as mentioned above)
eebbesen
  • 5,070
  • 8
  • 48
  • 70
0

I typically store all my Heroku projects in a dropbox folder that is sync'ed to all my computers (also doubles as a very handy backup layer) - I also store my SSH keys in dropbox and then each computer symlinks ~/.ssh to the dropbox path - that way, I use the same key across multiple computers for the same account.

I have never pulled a project from Heroku since working in dropbox folder means all my computers are using the same code but if you're using Github then you don't need to clone from Heroku since your master branch locally and on github should be what is presently live on Heroku and then you should be working in a branch that is merged into master to go live.

This means I can be working on any computer and have the same code in front of me and just need to bundle/migrate my projects to be up and running but there's no reason why you can't just have the project setup and pull from github at which ever computer you're add and provided you add the heroku remotes on both computers you'll be fine.

John Beynon
  • 37,398
  • 8
  • 88
  • 97
  • 1
    I don't know if linking your ssh keys to dropbox is a good idea... That's my main prob actually with this setup. I share all the conf files through dropbox except my keys... – patm Dec 29 '12 at 23:08