2 August 2007, mid-afternoon
This is a brief guide for those who want to build and install Git under MacOS X. The install process is fairly straightforward. The only hiccup is that the development environment for MacOS X 10.4 doesn’t come bundled the Expat XML Parser. I’m not sure who these instructions will be helpful to, as most people bothering to install Git probably know what they’re doing.
If you follow the steps below you will end up installing Git in
/usr/local. If you haven’t already done so, make sure that /usr/local/bin is in your $PATH. Open up your
.bash_login file and add the following, if you don’t see the path there already:
The search path is what your shell uses to determine the location of programs it can run. When you type
git in the command line, it will scan through the various directories it knows applications are stored looking for
which command can be used to determine where an application is running from — i.e. after you have installed Git, the command
which git should return
Before we can build Git, we will need to download, build, and install the Expat XML parser. If you are on Leopard you can skip this step. The latest version of the library is 2.0.1, which can be downloaded from the project’s Sourceforge site. Once downloaded, open a terminal window and change to the directory the file is located. You’ll need to run the following commands:
tar xvzf expat-2.0.1.tar.gz cd expat-2.0.1 ./configure --prefix=/usr/local make sudo make install
This will build and install the Expat library and header files in
/usr/local, which is where you should be installing 3rd party libraries such as this. The first command extracts the source code from the archive you downloaded. The
configure script is used to simplify building applications and libraries across multiple platforms.
configure will perform some tests to make sure your system is capable of building the library, and will generate the Makefile used in the actual compilation process.
make is what actually builds the program, executing all the commands needed to turn the source code into a working program;
sudo make install is what actually copies the library and header files to their final locations. The reason we need to run
make install with super-user privileges is that your normal account doesn’t have write access to
Once done, you can now build Git. The process is similar to what was done to build the Expat library. You can download the latest version of Git from its home page — currently this is version 220.127.116.11. Once downloaded, open up your terminal again and change to the directory the archive is stored. You’ll need to run the following commands:
tar xvzf git-18.104.22.168.tar.gz cd git-22.214.171.124 make configure ./configure --prefix=/usr/local make all sudo make install
You can erase the source directories,
expat-2.0.1, if you are so inclined.
You now have a working copy of Git. You can now type Git on the command line to see what all the fuss is about. If you have no clue what to do next, check out the tutorial online.
(Note: I haven’t covered building and installing the documentation here, as it is more trouble than it’s worth — trusts me. All the documentation is available online.)
Update 0ct 28th: You do not need to download and install Expat for Leopard. Expat comes installed Leopard.
Update March 1st 2008: See this comment below if the build process complains about gettext. I believe this is a requirement of the tcl-tk GUI Git ships with.
Update March 10th 2010: This advice on installing the man pages without building works perfectly.