el­studio

Building Git on Leopard

So you want to use Git for distributed version control For Mac OS X 10.5 there are a couple of options for installing Git.

  • Fink packages an almost up-to-date version, named simply git
  • MacPorts packages an up-to-date version as git-core

Either of these methods, though, installs lots of dependencies. Which requires lots of compile time. And lots of disk space – especially for the MacPorts version.

So I prefer to compile Git myself – and use Fink for dependencies. Here’s how I do it.

Install Fink by following Fink’s installation instructions.

fink install gettext-tools expat1-shlibs

From here the instructions in Git’s INSTALL file work just fine:

curl -O http://kernel.org/pub/software/scm/git/git-1.5.4.5.tar.gz
tar zxf git-1.5.4.5.tar.gz
cd git-1.5.4.5
make prefix=/usr/local all
sudo make prefix=/usr/local install

Now for the manpages.

Rather than build the docs ourselves (which requires asciidoc and a host of dependencies), I prefer to download them precompiled from Git and manually copy them into /usr/local/share/man.

curl -O http://kernel.org/pub/software/scm/git/git-manpages-1.5.4.5.tar.gz
sudo tar zxf git-manpages-1.5.4.5.tar.gz  -C /usr/local/share/man

(Replace the version numbers here with what’s right for the version of Git you’re installing.)

Now we’re ready to try this out, we’ll ask what version we just installed, then show the manpage:

git --version
man git

Done. Happy versioning!

Update

Sean Santry has an even simpler way to avoid the gettext-tools dependency – by telling make that we don’t have msgfmt at all.

NO_MSGFMT=yes make prefix=/usr/local all
sudo make prefix=/usr/local install

Using this tip you can build Git without Fink altogether!

2 Comments on the Original Post

You can also just install a complete OS X package from http://code.google.com/p/git-osx-installer/ It’s only 3.6MB and spares you the manual install

Pieter de Bie 4 Apr 2008, 10:31 AM

That’s great, Pieter — thanks for the link to a pre-compiled installer for OS X. And these instructions for building your own package look good, too.

– Eric Johnson 4 Apr 2008, 12:59 PM