When I set up a new quick-and-dirty app on heroku... I often also want to put my code up on github.
I was really surprised this simple process wasn't covered in the otherwise pretty excellent Getting started with Rails 4 post on heroku.
It's pretty straightforward, so here it is.
If you follow the instructions as per the getting started guide (above), you'll have a local git repo, and it'll be tracking the heroku remote as "heroku". which means there's no problem with using the bog standard "origin" for your github repo version.
So from there
Step 1 create a new repo on github
- Go to your github page eg this is the github page for me: taryneast's github
- Click on the "repositories" tab
- Click the green "new" button
- Give it a name and, optionally, a description
- Click "create repository"
Step 2 - link it to your heroku app
- Go to your heroku app's settings page. this will be something like: https://dashboard.heroku.com/apps/<myapp>/settings
- About halfway down you can add your repo-name. It'll be <mygitusername>/<mygitrepo>
- Click save
Step 3 - link your local repo to the github remote
- open a terminal in your rails app's root directory
- type git remote add origin email@example.com:<mygitusername>/<mygitrepo>.git
- git push -u origin master
Your heroku app is now on github.
You can continue to push to heroku with:
git push heroku master
and to github with:
git push origin master