Digital Magpie

Ooh, ooh, look - shiny things!

How to Work With Git & GitHub

Based on Alex’s comment on the Leiningen group, here’s my shiny new setup for working with Git & GitHub on OS X, I’m posting it here then it’ll be easy for me to refer back to in future…

Installing the Tools

  1. install MacPorts if you don’t already have it;
  2. get an up-to-date version of ruby and rubygems with sudo port install rb-rubygems;
  3. install the github tool with sudo port install json github; and
  4. upload your public key to your GitHub account.

Creating a New Project

Run github create project_name to create a public project, append --private to create a private project (you will need a paid account at GitHub for this).

Forking

Run github fork project_owner project_name, for example to create a fork of the Cucumber testing framework run github fork aslakhellesoy cucumber.

Making Changes

Make your changes in a branch, this took me a little while to get used to at first as it’s different from the normal way of working with version control systems like CVS:

1
2
3
4
$ cd project_dir
$ git checkout -b feature_name
... edit edit edit ...
$ git commit -a -m "Witty comment."

From time to time push the branch to github so others can see what I’m working on git push origin feature_name. If the work is in a fork then you’ll also want to send a pull-request back to the original project with github pull-request project_owner feature_name. All from the command line, neat huh? For more tricks, you can also browse issues with github issues {open|closed}.