Install Git 1.8.x on RHEL 5 and 6

If you are running RHEL 5, you may already know that Git is not located in the official RHN repositories. You can always install it from EPEL. However, EPEL contains an older version: (at the time of this post). RHEL 6 has Git in the official RHN repositories, but, it’s based on Git 1.7.1. For most users, this might be fine, however, if you have a need or want to use the latest and greatest version (or have everyone using the same version), then you will need to build the newer ones from source.

The Problem:

Installing version 1.8.x might seem as simple as downloading the source and running make. (This post uses Git version 1.8.1 as the example.) Unfortunately, building Git v. 1.8.x isn’t that simple on RHEL5, and I will explain why below:

After you download and extract the source code, there is an INSTALL file that outlines instructions on how to build Git. According to that file, you would run the commands:

	$ make prefix=/usr all doc info ;# as yourself
	# make prefix=/usr install install-doc install-html install-info ;# as root

Running this command on RHEL 5 will fail…But not because of the Git binaries. It will fail when generating the documentation. The problem is that the documentation needs to be built with AsciiDoc. AsciiDoc is found in EPEL, but the version on EPEL is too old to properly build the Git documentation. Even if you build the latest version of AsciiDoc, it still won’t work because it depends on a newer version of DocBook XML files. Unfortunately, the DocBook XML files on RHEL 5 are really, really old (Source).

Thus, you cannot (easily) build the documentation on RHEL 5, BUT: you can still build Git and get the documentation!

The Solution:

The Git developers know that the documentation can be hard to install, so they provided a workaround to installing it. Per the Git installation documentation:

There are also "make quick-install-doc", "make quick-install-man"
and "make quick-install-html" which install preformatted man pages
and html documentation. To use these build targets, you need to
clone two separate git-htmldocs and git-manpages repositories next
to the clone of git itself.

I will explain how to make this work. But first, we need to build the Git binaries without the documentation packages. So, run the command below while inside of the Git source directory to build Git:

$ make prefix=/usr all
$ sudo make prefix=/usr install

**Notes for the above commands:

  • Do not run the first command as root. Run this as your non-root user.
  • Git is cool in that you don’t need to run the /.configure script, you just make it.
  • You ALWAYS need the prefix. Don’t just run make in this case! (This is also true in the installation.)

The above commands will compile and install Git. As for dependencies, you will obviously need the build tools, openssl, openssl-devel, libcurl, libcurl-devel, expat, and expat-devel. There may be one or two more, but this seems to work for me. You can use yum to install them. This works for both RHEL 5 and 6.

As of this point, you have the git binaries installed. You can verify this by opening a terminal and running the command: $ git version. It should return the version number of Git that you downloaded. You are missing the man pages for Git, as well as the HTML documentation files. I would highly recommend installing the man pages, but at this point, you can fully use Git.

Installing Documentation:

Having the man pages are very useful. We’ll also install the HTML pages as well. So, to install them, we are going to fetch the docs that are pre-made. These are just text and HTML files; there is nothing special about them, but we need to move them into the appropriate directories so that they are useful.

In the previous section, I pasted in instructions from the INSTALL file on how to do this. However, if you are like me, you will find that really confusing. In fact, I submitted a StackOverflow question about this. Fortunately, I figured it out and answered my own question. For convenience, I have pasted the instructions below:

  1. First, open a terminal, and cd to the parent directory of the directory containing the Git source code. Meaning, if you are inside of the Git directory, simply run the: $ cd ../ command.
  2. Once directly outside of the Git source directory, you need to Git clone the repositories containing the documentation files (remember, we just installed Git!). Do that by running:
    $ git clone git://
    $ git clone git://

    Now: Here is a REALLY GOOD QUESTION:WHY didn’t the author(s) of the documentation include these locations? Seriously, WTF? I’m not psychic. But whatever, I eventually found them…

  3. Once you have the files downloaded, cd back into the Git source code directory, and run the EXACT commands below to install them:
    $ sudo make prefix=/usr quick-install-doc
    $ sudo make prefix=/usr quick-install-html

At this point, you can test this out by running the command: $ man git, and you should see a man page for Git. If you can see the man pages, then congratulations! You are done!

Many environments require the umask setting to be made more restrictive. This is typical in many secure production environments. This will cause a bit of a problem when installing the docs. The problem is that although the files are installed, their permissions are set such that standard users do not have permission to see the man pages. This can be fixed by running the following commands (as root!):

$ find /usr/share/man/man1 -type f -iname "git*" -exec chmod 644 {} \;
$ find /usr/share/man/man5 -type f -iname "git*" -exec chmod 644 {} \;
$ find /usr/share/man/man7 -type f -iname "git*" -exec chmod 644 {} \;

## If you installed the HTML docs as well, you need to do:
$ find /usr/share/doc/git-doc -type f -exec chmod 644 {} \;
$ find /usr/share/doc/git-doc -type d -exec chmod 755 {} \;

Remember, make sure those commands are run as root! That should fix any permission issues resultant from restrictive umask settings.

Copyright © /sarc All Rights Reserved · Using modified version of Green Hope Theme by Sivan & schiy · Proudly powered by WordPress