Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save amratab/f0402023194be56c7569fea08e249631 to your computer and use it in GitHub Desktop.
Save amratab/f0402023194be56c7569fea08e249631 to your computer and use it in GitHub Desktop.
Adding multiple heroku apps to a single repository different branches
Suppose you have two heroku remote apps
myapp-dev & myapp-prod
and two git branches
master(for dev) & production
Now lets setup heroku on the existing git repo in your local machine
Assuming the branches and the apps exist already
git remote add heroku-myapp-dev https://git.heroku.com/myapp-dev.git
git remote add heroku-myapp-prod https://git.heroku.com/myapp-prod.git
git remote -v
should show something like this
heroku-myapp-prod https://git.heroku.com/myapp-prod.git (fetch)
heroku-myapp-prod https://git.heroku.com/myapp-prod.git (push)
heroku-myapp-dev https://git.heroku.com/myapp-dev.git (fetch)
heroku-myapp-dev https://git.heroku.com/myapp-dev.git (push)
origin git@bitbucket.org:username/myapp.git (fetch)
origin git@bitbucket.org:username/myapp.git (push)
Now if you want to push your master branch to a particular heroku app
git push heroku-myapp-prod master
To push the other branch(production being the other branch)
git push heroku-myapp-prod production:master
@mattcarpowich1
Copy link

super helpful, thanks!

@amr3k
Copy link

amr3k commented May 28, 2021

Thanks so much

@harcop
Copy link

harcop commented May 5, 2022

Thanks

@chrisheseltine
Copy link

I suspected this was possible but wasn't sure cuz heroku use a different git notation to set the default remote. Thanks a lot!

@KingLearned
Copy link

hello please i have a question.

Assuming I have two Apps created by heroku example (the 1st has the name 'www.herokuapp.vexhub.com' and another 'www.herokuapp.winword.com')

Now how do I push to any of the apps respectively, like pushing to the 1st or the 2nd?

Thanks

@JUNKI555
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment