Categorized: Apple, Git, TextMate

Installing Git on OS X Leopard

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.

If you haven’t already, stick your Leopard disk in and install Xcode 3.0.

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:

Comments

Tim Harper → April 3rd, 2008 at 3:02 pm

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/

Ian White → May 19th, 2008 at 9:22 am

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

Arthur → June 1st, 2008 at 11:36 am

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

Panasonic Youth – Git 1.5.6 released → June 18th, 2008 at 10:51 pm

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

justG → June 30th, 2008 at 9:02 pm

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.

Jason Rudolph → July 4th, 2008 at 11:49 am

Somehow, someway, I lost my Git man pages during the upgrade. Doh!

In case anyone else ends up in the same boat, these two commands will install the 1.5.6 man pages and get you back on track:

curl -O http://www.kernel.org/pub/software/scm/git/git-manpages-1.5.6.tar.bz2

sudo tar xjv -C /usr/local/man -f git-manpages-1.5.6.tar.bz2

RAILS66 » Blog Archive » Installing Merb → July 13th, 2008 at 9:27 am

[...] Installing Git on OS X Leopard(MacPorts) [...]

Chris McCall → July 15th, 2008 at 7:48 am

Thanks for the solutions log Trey! For the Macports version of the install you probably want to have xcode installed. To ease the pain.

Trey → July 15th, 2008 at 8:30 pm

Added that to the post. Thanks, McCall.

What do you think about that?

Elsewhere in the empire: Home, Blog, APOD