Recipe: Building and Installing Git

04 Oct 2008
Posted by Jeet Sukumaran

Getting the Source Code

The source code can be downloaded from http://kernel.org/pub/software/scm/git/:

$ curl -O http://kernel.org/pub/software/scm/git/git-1.6.0.2.tar.bz2
$ tar xvf git-1.6.0.2.tar.bz2
$ cd git-1.6.0.2

Building/Installing on Linux (Ubuntu/Debian)

Building and installing Git on Ubuntu is quite straightforward (including installation of documentation), provided that all the dependencies are available:

$ sudo apt-get install libexpat1-dev zlibc curl gettext zlib1g-dev libcurl3-openssl-dev
$ ./configure --prefix=/usr/local
$ make prefix=/usr/local all
$ sudo make prefix=/usr/local install

Building/Installing on Mac OS X (Leopard)

The Binaries

Building Git on Leopard is not as straightforward as one might wish, as several environmental variables need to be set to get it right:

$ make configure
$ ./configure --prefix=/usr/local
$ export NO_MSGFMT=yes
$ export NO_PERL_MAKEMAKER=yes
$ sudo make LDFLAGS="-lobjc -L/usr/X11R6/lib/" CFLAGS="-I/usr/X11R6/include/" prefix=/usr/local install

The Documentation

Installing the documentation is also troublesome on OS X. In theory, the following should do it:

$ make install-doc

But it won't. Don't bother jumping through a bunch of hoops trying to get it to work. It won't and you will just end up frustrated. Instead, just download the man pages archive from here , unpack it to "/usr/local/man" (or elsewhere), and set the MANPATH environmental variable appropriately, if neccessary:

$ curl -O http://kernel.org/pub/software/scm/git/git-manpages-1.6.0.tar.bz2
$ sudo tar xvf git-manpages-1.6.0.tar.bz2 -C /usr/local/man
$ export MANPATH=/usr/local/man:$MANPATH # add to .bashrc

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a biological visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.