Rob Williams is a probabilistic Lean coder of Java and Objective-C. Rob is a DZone MVB and is not an employee of DZone and has posted 170 posts at DZone. You can read more from them at their website. View Full User Profile

Super Quick Git Setup Guide for OS/X

  • submit to reddit

First, go get the source. Building it on my machine, and even on my mini server was a snap. Here are the commands:


cd /usr/local
mkdir src
cd src
curl -O
tar -xjvf git-
cd git-
./configure --prefix=/usr/local
sudo make install
git --version


Should take a few minutes.

Then, go make a project. I created a java one with a maven archetype, then this morning I did one for Xcode. If you are going to use git with Xcode, you will want to create a .gitignore with the following inside:


# xcode noise

# osx noise

and a .gitattributes file with the following inside:

*.pbxproj -crlf -diff -merge

Then, I ssh'ed into my remote machine. I know git is distributed, but there are still a lot of reasons to have a place that has a copy of the code that everyone can get to.

I made a directory on the mini for all repositories and made a site: repositories.<domain name>. Then I created several subdirectories for grouping my repos. For each subdirectory, I made a security realm. So I can finally have domain model stuff in one place, analytics stuff in another, and have granular control over the permissions! The setup in the mini was super simple and clean. Back to the flow of setting up this one repository.. Once I ssh'ed in, I go to the directory where I want to put the new repo, and do:


sudo mkdir <projectname>.git
cd <projectname>.git
git init --bare
git update-server-info

Then, you have to back out of the dir you are in and chown all dirs and their contents to your www user. My command was:


sudo chown -R _www *

Now we can go back to the window with the local repo and do:

Then, there are a bunch of tutorials that cover the basic sequence of git. Here are the commands to add your project to the repo:


git init
git add .
git commit -m "Initial commit."
git remote add origin https://<path to repo>
git push origin master

and we are done. Per my earlier posts, you have to get over the ssl issue by either adding ssl to curl and getting it to see your cert or disabling ssl checking.

Git gets high marks for the way they implemented their commands and they way the app responds to those commands: if you bone up commands, it even suggests what you might mean sometimes. Heuristics are important, but you will still need a cheat sheet. It's also very communicative so you rarely are left wondering if what you did worked or where you ended up.


Published at DZone with permission of Rob Williams, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Thomas Kern replied on Thu, 2012/09/06 - 11:01am

You might consider using Homebrew instead ( It's comparable to MacPorts but much lighter weight. 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.