Building notes, projects, and occasional rants

Compiling git on Mac OS X

I had to install git on my temporary G4, and I didn't kept proper notes before, so for future reference, here is my way of compiling git.

This was tested on 10.4.11. I haven't upgraded to 10.5.x yet, maybe when 10.5.2 comes out.

I don't use MacPorts or fink, I don't like them. Its a personal thing, and if you do like them, you might as well use them instead.

First, let me tell you that I keep several git versions around. I install them in /usr/local/git-VERSION and switch a symbolic link at /usr/local/git to point to the version I want. Also, when I compile directly from a git checkout, I use the SHA1 of the HEAD as my VERSION. My PATH includes /usr/local/git/bin to find the latest version.

Second, I haven't bothered yet to compile asciidoc, so I don't compile/install the documentation.

Compiling the released version

Download the latest version of git from the git home-page.

mkdir ~/src
cd ~/src
curl -O${GIT_VERSION}.tar.gz
tar zxf git-${GIT_VERSION}.tar.gz
cd git-${GIT_VERSION}
./configure –prefix=/usr/local/git-${GIT_VERSION}
make all

If you get a compile error, something like:

    SUBDIR git-gui
    MSGFMT    po/de.msg make[1]: *** [po/de.msg] Error 127
make: *** [all] Error 2

It means that you would need to compile GNU gettext to get msgfmt. Just do:

export NO_MSGFMT=1
make all

and it will use a alternative TCL script instead. According to pfig, 10.5.x does not need this export at all.

To install:

sudo make install

Now, create a symlink:

sudo ln -s /usr/local/git-${GIT_VERSION} /usr/local/git

And add /usr/local/git/bin to your PATH:

echo 'export PATH=$PATH:/usr/local/git/bin' >> ~/.bashrc

Make sure you have the new PATH:

exec bash --login
git --version

Now go play with it.

Living on the edge

But I don't stop here. The stock version of git is fine, but I usually use the master branch. So after you gone through all that, you do it again.

I keep a clone of the git master branch and update it from time to time. To clone the first time, do:

mkdir ~/projects
cd ~/projects
git clone git://

If your firewall doesn't allow outgoing TCP on port 9418, try:

git clone

You only need to do this steps once. From then on, whenever you want to update to the latest git, do:

cd ~/projects/git
make distclean
GIT_VERSION=`git-show | head -1 | cut -c8-`
# I should be able to do GIT_VERSION=`git-show --pretty=format:"%H"`
# but I could not get it to work...
./configure --prefix=/usr/local/git-${GIT_VERSION}
export NO_MSGFMT=1
# See above why export NO_MSGFMT=1
# You can try without it and use it only if it fails...
make all
sudo make install
sudo rm -f /usr/local/git
sudo ln -s /usr/local/git-${GIT_VERSION} /usr/local/git
git --version

That's it. You should be using the latest git available now.