Github and Heroku: A Beginner’s Guide

Carmelle Millar
Aug 27, 2017 · 2 min read

Disclaimer — I’m by no means an expert on Github nor Heroku. Just a beginner trying to help others who might be having the same problem. So if I mess anything up here, please tell me! Thank you.

I don’t recommend the following advice for teams, only for individuals trying to keep their public repo updated.

The objective was to display my code on Github, as a portfolio. Sounds simple, right? After all, Heroku allows you to connect to a remote repo. See their Github Integration documentation.

They claim that:

When GitHub integration is configured for a Heroku app, Heroku can automatically build and release (if the build is successful) pushes to the specified GitHub repo.

This simply did not prove to be true, however, when deploying to the heroku remote. git push heroku master wasn’t doing anything to the repo on my Github page, even though the web app was updating correctly.

I don’t know if that’s a common error, but here’s how I fixed (*cough* forced) it.

> git remote add github https://github.com/username/repo.git

This adds your personal repo to the current directory. If you type git remote -v you should see two lines which begin with github, and two lines that begin with heroku.

> git push github 

Should update your public github repo, which is separate from the private repo that heroku utilizes. But personally, I just kept getting this error:

Pushing to git@github.com:519ebayproject/519ebayproject.git
To git@github.com:519ebayproject/519ebayproject.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:519ebayproject/519ebayproject.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

This example error taken from this StackOverflow post.

I tried git pull heroku, git add . , git commit -m “please work” , which is the safe! way—to no avail..

So I resorted to this command which can erase previous commits so please be careful!!

git push -f github master

This basically forces github to ignore all the warnings and just commit to your repo.

)

Carmelle Millar

Written by

Studying Computer Science at Stanford University

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade