So I understand that heroku functions as a git repository, but let's say i want to use github as well as a repository. How do I set it up such that I have two repositories and both are in sync?
Heroku comes with it's own server so you can purchase hosting plan & deploy you web apps easily. In case of Github you need to purchase a separate server to host your web apps. Github is well known for contribution & collaboration & Heroku is for backend stack available for collaboration & deploying easily.
"Free", "Right out of github" and "Quick to set up" are the key factors why developers consider GitHub Pages; whereas "Easy deployment", "Free for side projects" and "Huge time-saver" are the primary reasons why Heroku is favored.
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 branch git push heroku master -- push to Heroku
First add them:
git remote add origin <github repo> git remote add heroku [email protected]:<app name>.git
Then push
git push origin master git push heroku master
Edit you configuration file so origin
points to both heroku and github:
git config -e
Add/Replace:
[remote "origin"] url = [email protected]:username/somerepo.git url = ssh://[email protected]/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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With