Friday 20 July 2012

Github for one...

While I'm doing client work, I always use version control software to keep all the different files locked away and secure.  With PeopleSoft, there are tens of thousands of files, so it's kind of important not to loose track of them.  With my own iOS development, however, I've always avoided using git or the like as I didn't see the benefit.  After the game hack at iOS Dev UK, I've changed my tune and now think it's a great idea!

My approach was always to do manual version control.  I'd just have a bunch of whole directory copies of a project and every now and then I'd clone the whole thing.  As it was just me working on these projects, this worked fine.  If ever I had a slip up, I could just go back to the last version in the backup directory and manually sort things out.

The one issue I had with this was switching between my Mac Book and my Mac Mini.  It was always a bit hair raising when I copied the whole directory from one machine to the other.  The first step was usually to delete the whole thing on the target machine, which was always scary.  I did try setting up a local server, but this never quite seemed to work and was a bit annoying.

During the game hack, however, our team relied heavily on Github to share all our source code.  Previously, when I did use git, it was through the git built into XCode.  That worked OK, but I found I spent more time battling it than using it properly.

This all changed when I started using the stand alone Mac client.  Sure, it has it's flaws, but OMG, when it works, it works well!  With a few button press, you can commit your latest changes, backup the whole project to the web, then distribute it to all your machines.  WOW.  Until I saw this in action, I never saw the point of this type of version control, but when you add in off site cloud backups and internet based distribution, it's magic!

To get things working, you need the Github client from mac.github.com and a Github account.  The slight catch is that the free account only allows you to create public repositories.  To create the private ones that you really want, you need to subscribe.  After using it for a week now, it's definitely worth the $7 a month I'm paying.

As I mentioned, a great feature is that all your code is backed up to the cloud.  This is as huge comfort if you're worried about off site backups.  It's also an amazingly useful way of looking at your past commits and hence prior versions of your code.  Doing the same within XCode can be a bit of a pain, but the simple web interface allows you to look at your code in a really simple way.  Great stuff!

There are a few annoyances with git.  Sometimes it adds things to your project it shouldn't - things like the position and layout of your windows and other project type preferences.  Merging branches can also be a pain and can lead to the corruption of the project file.  This is easily fixed using a text editor, but it's a bit of a pain.  A few googles on using .gitignore sorted most things out, so it's not a show stopper.

In the space of a week, I've gone from wondering why you would bother with the overhead of version control to using it regularly to actually make my work easier.  Great stuff!

4 comments:

  1. I've just been told that a free alternative to github is Bit Bucket. It allows private repositories with up to 5 collaborators. Good stuff.

    Thanks Luke!

    ReplyDelete
  2. Intriguing - could you perhaps write more about your actual workflow? How does the stand-alone client integrate with Xcode (or doesn't it?)

    ReplyDelete
  3. There's two ways you cango about things. One method is to use the github Mac app to do everything. While it's running, it monitors all the files in the repository and then lets you do a commit for the lot. From there, you can then push and pull the repository to any other clients.

    BUT... I've had a few problems with this. My approach is to use the git commands from within XCode - File -> Source Code -> Commit, Push, Pull etc. to do the project commits. When I want to distribute it my other machine, I then go to the github Mac client and press the "Branch in Synch" button which does the upload to the internet repository.

    From the other machine, I just go into the github app, press "Branch in Sycnh" and it automagically updates to the latest version.

    It's possible to do all this using just the commands in XCode, but I think the special sauce in the github app just makes things a lot easier.

    Hope that helps!

    ReplyDelete
  4. There's a great set of videos over at o'reilly that cover git on the command line if you ever want to go that way http://shop.oreilly.com/product/0636920017462.do

    Combined with TotalTerminal http://totalterminal.binaryage.com/ (free) you can commit and a lot more without taking your fingers off the keyboard.

    ReplyDelete