el­studio

4 Steps to Happiness Working with GitHub Projects

Git is a great (and fashionable) source control management program. GitHub takes the pain out of hosting Git for a group – for both open-source and private projects. How to best use them together? The Way to Happiness has these 4 steps:

  1. Fork the project on GitHub, and clone your version. This gives you your own copy to work with.
  2. Make a branch (or frequent branches) for what you’re working on. Some folks systematize this with issue names and bug numbers – like “RedoPostFormatting-234” – which is probably a good idea for projects with lots of collaborators.
  3. If you reserve certain branch names, like “master” and “staging” for production and pre-production code, you can merge a project’s code back into your tree more easily.
  4. Or use the github-gem command line tool to grab a copy of somebody else’s code when needed. Here’s the salient snippet from the readme:

Let’s say you just forked github-gem on GitHub from defunkt.

$ github clone YOU/github-gem
$ cd github-gem
$ github pull defunkt

This will setup a remote and branch for defunkt’s repository at master. In this case, a ‘defunkt/master’ branch.

If defunkt makes some changes you want, simply github pull defunkt. This will leave you in the ‘defunkt/master’ branch after pulling changes from defunkt’s remote. After confirming that defunkt’s changes were what you wanted, run git checkout master and then git merge defunkt/master to merge defunkt’s changes into your own master branch.