Skip to content

Github Resources and Recipes

gte959f edited this page Sep 17, 2013 · 1 revision

###Good resources for Git

There's a cheatsheet link once you've experimented a little that is handy

The Git, Github, Heroku pdf has some good nuggets.

http://git-scm.com/documentation

Stanford tutorial

http://www-cs-students.stanford.edu/~blynn/gitmagic/ch02.html

This is a great tutorial on doing this basic workflow in git. SmartGit might make this a bit more visual, but I think its important to know how git itself works in this manner.

http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging

https://devcenter.heroku.com/articles/multiple-environments

Read these to get into the zen of the branching

###0. Concepts a. git is a distributed version control system. This means there's local and multiple remote repositories and all these can be in different states at different times.

b. git also has the concept of branches which are basically pointers to different points of history within a repository.

c. local branches and remote branches are not the same thing. You can make them track each other, but it takes a command line option. (i believe -u). This makes it so that when you push from a local to a remote you don't have to specify the frombranch:tobranch since its saved locally.

d. For the most part, there's three main repositories a developer on this project needs to worry about.

  1. Their local repository in the directory they've created or cloned to.

  2. The github repository for utilifit which serves as the shared source of truth for the team and our code for the project.

  3. The deployment repositorie(s) which sit inside of each Heroku environment.

e. Best to get familiar with branching and merging per the sections below. Click through additional links in the git-scm to understand more advanced use cases like going back in time and cherry picking particular commits.

###1. Basics of Branching and Merging (locally)

http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging

###2. Pushing your local branches up to github http://www.mariopareja.com/blog/archive/2010/01/11/how-to-push-a-new-local-branch-to-a-remote.aspx

If you get strange errors or are curious check out some github documentation

https://help.github.com/articles/pushing-to-a-remote

###3. Deploying from a Branch to Heroku

https://devcenter.heroku.com/articles/git#deploying-code

This will push your code to the heroku remote, created earlier. Branches pushed to Heroku other than master will be ignored by this command. If you’re working out of another branch locally, you can either merge to master before pushing, or specify that you want to push your local branch to a remote master. To push a branch other than master, use this syntax:

$ git push heroku yourbranch:master

Occasionally if multiple developers have been pushing to the same environment from different branches you may get a "non fast forward" error. This means that the branch pointer that the Heroku repository is current at is does not have a single ancestor parent with the push you are trying to make. Most of the time its ok to "force" past this since we never really pull code down from Heroku and only want to overwrite the latest build. In that case, issue a force (never do this on github unless you know what you are doing):

$ git push heroku yourbranch:master --force

Clone this wiki locally