Installing Git on OS X Leopard

Posted by Trey on February 25, 2008

It’s apparently best to install Git using both MacPorts and from source. That way you’ll get all the dependencies that are a pain in the ass to get set up, and you’ll also get the newest version of Git.

Install Git + Dependencies from MacPorts

Install the MacPorts “Leopard (Universal)” disk image from here.

If after the installation, running “which port” doesn’t show “/opt/local/bin/port“, try adding the following lines above any other path rules you have in your .bash_login file:

# MacPorts
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH
# / MacPorts

Make sure MacPorts is up-to-date:

sudo port -v selfupdate

Install Git:

sudo port install git-core

Install Git from Source

Go to git.or.cz and download the newest package.

Stick the file where you want it (I prefer /usr/local/src/).

Open the file and cd into its folder. Then:

sudo make prefix=/usr/local all

(You won’t need the sudo on the last command unless you’ve got your source in /usr/local/src/, which is owned by root)

Then:

sudo make prefix=/usr/local install

If everything goes as planned, you should be able to type “which git” and see exactly this:

/usr/local/bin/git

If instead you see /opt/local/… you’re using the MacPorts version and you need to move those path rules above the other rules in your .bash_login.

Enjoy.


Bonus: TextMate Integration

To use TextMate to edit your commit messages, put the following in your ~/.bash_login:

export GIT_EDITOR="mate -w"

Install the TextMate Bundle:

mkdir -p /Library/Application\ Support/TextMate/Bundles
cd !$
git clone git://gitorious.org/git-tmbundle/mainline.git Git.tmbundle
osascript -e 'tell app "TextMate" to reload bundles'

Since Git is installed in /usr/local/bin, you’ll need to make a link to where the bundle expects it:

sudo ln -s /usr/local/bin/git /usr/bin/git

Sources:

Trackbacks

Use this link to trackback from your own site.

Technorati

View blog reactions

Comments

Leave a response

  1. Tim Harper Thu, 03 Apr 2008 15:02:41 PDT

    Even more of a bonus: Geoff Cheshire and I have been putting together some Git installer packages for OS X:

    http://code.google.com/p/git-osx-installer/

    Additionally, for some really great textmate integration:

    http://gitorious.org/projects/git-tmbundle/

  2. Ian White Mon, 19 May 2008 09:22:45 PDT

    Thanks for the writeup. If you’re interested in hosting git on your leopard machine, then I’ve written a writeup over at blog.ardes.com

  3. Arthur Sun, 01 Jun 2008 11:36:06 PDT

    Interesting, especially the compiling from source. I also wrote about Git on OS X some time ago with a little more focus on the installation from MacPorts and Configuration. You can find it here

  4. Panasonic Youth – Git 1.5.6 released Wed, 18 Jun 2008 22:51:58 PDT

    [...] directions posted here worked fine for me to upgrade my existing source based installation in [...]

  5. justG Mon, 30 Jun 2008 21:02:30 PDT

    Thanks so much for these incredibly easy-to-follow, accurate instructions. Everything worked exactly as it was supposed to with no errors, which is pretty much a first for me.

Comments

Live Preview: