Git on Mac OS XNov 18, 2008 Git Mac OS X Tweet
Okay, forget what I just said about svn on OS X. This week, I'm moving one of my projects into a private repo on github. Why? Well, obviously because it's the new hotness. Because all the kids are doing it? Actually, the answer is "why not?". It can't hurt to learn another source control tool, and I've heard enough good reviews from friends to make me want to see what all the fuss (or lack thereof) is about.
The first step is to set it up locally, though. Start by downloading git: http://git-scm.com/download
If you really want to compile it yourself (and normally I would), there are some fairly verbose guides here and here.
I found this installer first though - it worked without a hitch: git-osx-installer
Pop open a terminal and check out your git install:
Now back to the code - I tarred up my existing project (originally in svn):
$ git help log
$ git --version
Remove the directory:
$ tar cvfz project.tar.gz --exclude=.svn projectfolder/
Untar the project again, cd into the folder, and run init:
$ rm -rf projectfolder/
Add the project to a git repository:
$ tar xzf project.tar.gz
$ cd projectfolder/
$ git init
$ git add .
The git commit process reminds me of cvs - assuming you're in the terminal and using vi, you'll have to open the file, insert your comment, then close and save in order to complete the commit.
$ git commit
Check the status of your repo (similar to svn's 'svn info'):
$ git log
One other thing to note: If you're using github, you'll be creating a local config file that sets up your connection to the github repository. You'll be able to check out, but you may need to add an extra line to allow you to push code back up to github (for more details, check here):
In the "remote" section, make sure you have that last line:$ vi .git/config
[remote "github"] url = firstname.lastname@example.org:git_username/projectname.git fetch = +refs/heads/*:refs/remotes/origin/* push = refs/heads/master:refs/heads/master