heroku and github at the same time heroku and github at the same time heroku heroku

heroku and github at the same time


You can have multiple remotes on a git installation. You would have a github remote, and a heroku remote.

Assuming you already have github setup, then you probably push to github with something like:

git push origin master

origin is your remote, and master is your branch.

Follow the instructions in getting started with Heroku choose your desired language and continue through the tutorial. This tutorial assumes that you already have github setup, and will show you how to create your heroku remote - via heroku create.

You then push to github as normal, and push to heroku via:

git push heroku master

The same format applies - heroku is your remote, and master is your branch. You are not overwriting your Github remote here, you are adding another, so you can still do both pushes via one commit with workflow such as:

git add .git commit -m "Going to push to Heroku and Git"git push origin master -- push to Github Master branchgit push heroku master -- push to Heroku


If you want to be able to push and pull to multiple remotes:

First add them:

git remote add origin <github repo>git remote add heroku git@heroku.com:<app name>.git

Then push

git push origin mastergit push heroku master

If you want to push to both remotes at the same time:

Edit you configuration file so origin points to both heroku and github:

git config -e

Add/Replace:

[remote "origin"]    url = git@github.com:username/somerepo.git    url = ssh://git@bitbucket.org/username/somerepo.git

Since you are using github you can integrate with heroku by navigating to:

https://dashboard.heroku.com/apps/<app name>/settings#github-repo

and adding your repository's name.

github integration

If you want to automatically push to heroku after committing to GitHub:

you will need to use a continuous integration platform like TravisCI.

Here are the steps to make this work. Be careful what you push to production, make sure it works before it gets deployed. Each method has its pros and cons.


I think this is actually the recommended case; the Heroku git repository function is really for deployment and not code management.

Just use github to manage your code as usual, but additionally push to the Heroku git repository when you are ready to deploy. There is no need to keep them in sync with automated tools etc., because you want to be able to push to your github repository without deploying, for instance so that you can back up or collaborate on unfinished features or maintain separate staging and production environments.