Installing git on Mac OS X
Thursday, July 30th, 2009I’m starting a new project where the source code is hosted on github so I had to install git on my Mac OS X. Git is an open source, distributed version control system. To install it on my Mac, I downloaded the installer package from google code (also available via MacPorts). After installing the package, I had to configure it to work with github.
Open the Terminal application (Applications->Utilities->Terminal).
Enter:
git config --global user.name "your name here" git config --global user.email your-email-address-here git config --global github.user your-github-user-here git config --global github.token your-github-api-token-here git config --global core.autocrlf true
If you receive the error:
git: Command not found
You will have to add the git directory to your PATH variables:
echo 'export PATH=/usr/local/git/bin:$PATH' >> ~/.profile
Restart Terminal and then enter:
echo $PATH
You should see that the git directory was appended to the PATH.
If you are using github, ‘github.user’ and ‘github.token’ can be obtained by clicking on your account link and then clicking on “Global Git Config”.
In order to use github, you will also need to create an ssh key:
ssh-keygen -C "your name or email address" -t rsa
To copy your public key to the clipboard:
cat id_rsa.pub | pbcopy
You can then paste it into the appropriate place on githubs site.
Note: id_rsa is the default name of your public key file. If you gave it a different name, then obviously you would ‘cat’ that name. Enjoy.



November 23rd, 2010 at 4:54 pm
It looks like by default terminal uses bash, and is actually loading up its reference from “.bash_profile” as opposed to “.profile”. So to add the git directory to my path variable, I modified:
echo ‘export PATH=/usr/local/git/bin:$PATH’ >> ~/.profile
to:
echo ‘export PATH=/usr/local/git/bin:$PATH’ >> ~/.bash_profile
I’m new to pathing on Mac OSX and took me about 1.5 hours to figure that out; hopefully this’ll save your beginning readers a bit of time setting up git.
-Mike
February 2nd, 2011 at 8:37 am
Thanks for this helpful content, and thanks to Mike it saved a lot of time, respect..
February 24th, 2011 at 10:56 pm
Oh man, thanks for that tip…that’s what I needed! To bad it’s already been 1.5 hours since I started looking for that fix. That’s what I get for being a newbie I suppose…
March 15th, 2011 at 11:54 am
Mike Ton – I would hug you if I could.
…and obviously hat tip to the OP.
July 24th, 2011 at 2:18 pm
hey thanks for the info, it really helped me out!
November 10th, 2011 at 7:32 pm
Oh god, I love u.
I went crazy with this.