Building git from source on El Capitan (OS X 10.11)

· by Steve · Read in about 2 min · (363 Words)

A quick post today because I didn’t find an easily accessible reference for building Git from source on Mac OS X El Capitan, and I needed to. Maybe there’s another post out there just like this one, but I didn’t find it, so maybe this will be useful in future for those who similarly come up short on Google.

After you’ve cloned the source from, open up a terminal. I’m assuming you’ve got Xcode installed, and that you’ve already installed the command line tools - if not, execute this on the command line now:

xcode-select --install

As with most command line builds, you now just need to go into the git source directory and run ‘make’. However the main issue you’ll get when doing this is:

./git-compat-util.h:213:10: fatal error: 'openssl/ssl.h' file not found
#include <openssl/ssl.h>
1 error generated.

The issue here is that the OpenSSL headers were removed in the 10.11 SDK included with the latest Xcode. You can fix that by using Homebrew to install them (if you’re not already using Homebrew, go here and follow the install instructions first)

brew install openssl

You might already have openssl from a previous dependency, but if not that will install it and put the headers and libraries in /usr/local/opt/openssl. You could also build openssl from source if you wanted, but Homebrew is faster and avoids me having to recurse down into how to build that as well in this post 😉

Once you’ve done that, run this variant of make:

NO_GETTEXT=1 make CFLAGS="-I/usr/local/opt/openssl/include" LDFLAGS="-L/usr/local/opt/openssl/lib"

Adding the CFLAGS and LDFLAGS pulls in your Homebrew installed openssl dependency, and the NO_GETTEXT=1 prefix ensures that the build skips trying to build translations, and just builds in English. You could install gettext from Homebrew too and add it to CFLAGS and LDFLAGS, but by default the Homebrew package only installs the headers/libraries, and the Git build requires its command line tools like ‘msgfmt’ too, which you have to manually add to your path. It’s not worth it, it’s easier just to build in English and be done with it 😉

With that, git should build just fine on El Capitan. Hope that helps someone else :)