Archive for February, 2009

Git on OS X Quickstart

I’ve actually been doing a little coding lately, thanks to an upcoming language shoot-out at Lambda Lounge in May.  I’ve almost got my first (only quasi-groovy) implementation complete and before I start on any refactoring, I figured it was a good time to get my version control on.

Since git is the new scm hotness, I figured I should give it a whack.  What follows is my extremely basic “just-get-me-going” instructions for OS X.

Step 1: Get git for OS X.  This is a binary release for OS X Leopard.  As of this writing, the latest version is 1.6.1.3

Step 2: Do your normal OS X install action on the downloaded binary.

Step 3 (Optional): Download GitX if you want an OS X native git GUI.

At this stage in the game you should be good to go.  Now it’s just a matter of creating your local git repo for your project. To do that, just cd to your project’s directory and type:

git init

Next, you’ll want to add everything in that directory into your local repo by typing:

git add .

Lastly, just commit it all…

git commit -m 'This is my first commit...blah, blah'

That should have you rockin’ for initial commits. The next thing I did (and which is completely optional) was to push my local repo up to my free (and therefore open source) account on github.

Once you create an account (and share your SSH public key) on github, you can then start creating projects. I created my “Vending Machine” project, then followed their directions to push up my local repo. I just entered the following commands:

git remote add origin git@github.com:danker/vendingmachine.git
git push origin master

A nice cheat-sheet on basic git commands can be found here.

More rsync’ing action

I’ve been doing some (light) development lately at night.  Depending on my mood, sometimes it will be from my desktop Mac, other times from my MacBook Pro.  I wanted to keep everything in my ~/Development directory in sync, so I figured I would whip up something hacky with rsync.

One of my main criteria was that I didn’t want the syncing process to keep around old files from one machine and copy them to the other.  To get around this, whenever I rsync from one machine to the other, I pass the –delete flag to the operation.  This can be dangerous…so I’m very careful that whenever I do a one-way sync (either “push” or “pull” in my parlance), I’m confident I’m not clobbering needed files on the target system.

I have 2 scripts that accomplish this:

The first one is my “pull” script.  This will pull all changes from the remote machine to my local machine.

#!/bin/bash

# "Pull" changes from remote machine directory to target directory on
# local machine.
# This will destroy any changes in target directory on local machine not
# present on remote machine.
# Sync via ssh and compress the files over the wire
rsync -avz -e ssh --delete eric@lenny.local:~/Development/ /Users/eric/Development

The second script is my “push” script.  Basically the same as above, but in reverse.

#!/bin/bash
# Sync the local directory to the remote server, this will "PUSH" the
# changes from local,
# destroying any changes in target directory on remote machine.
# Sync via ssh and compress the files over the wire
rsync -avz -e ssh --delete  /Users/eric/Development/ eric@lenny.local:~/Development

So there you have it.  Pretty basic pushing/pulling (remote mirroring) of files with rsync.