Chris Mendez in Tools for Software Engineers, For Developers, Git, Heroku

Heroku: Working with Git and Github

Heroku uses Git for version control and collaborative coding. Below are a few helpful commands plus a better process for app development.


Review remote

Review where you are hosting remote repos

git remote  
git remote -v  

Publish to Heroku

Publish to Heroku's master branch.

git push heroku master  

Revert the live push to Heroku

heroku rollback  

Review Releases

Review all the releases on Heroku

heroku releases  

Using Github + Heroku together

If you're planning to use Heroku as your primary web server, then you probably want to create a layer of separation between the code your working on locally, the code your submitting to Git and the code you see on the live website.

One good way of doing this is using Github with Heroku. The idea is to first write your code on your local computer, then publish your local work to a branch on Github, then merge that branch into your Github master, then publish the Github master to Heroku master. Although this seems like a lot of steps, it's a very healthy way to keep your team working continuously.

Merge the master of a Github repo to the Heroku master repo in order to keep keep things nicely organized.

git remote add github git@github.com:username/repo.git  

Double check that you added Github correctly

git remote -v  

Publish to Github's master branch

git push github master  

Creating an iterative process

In a previous post, I wrote about how you can use the concept of branches in order to create small, byte-sized sprints. The net effect is isolated, easier-to-organize sprints within a team.

This is how you can use an iterative process with both Github and Heroku at the same time.

Step 1

Make some changes to a file and review the changes

git status  

Step 2 - Create a branch on Github

This is where you will experiment no the Github branch.

git checkout -b name_of_branch  

Step 3 - Add files to Github branch

git add -A  
git commit -m 'message'  
git push github name_of_branch  

Step 4 - Merge branch into Master

git checkout master  
git merge name_of_branch  

Step 5 - Publish to Heroku

git push heroku master