Installing git from source on Centos 6.x

Problem

Couldn't clone github repos via https:// sources from Centos 6.2 boxes.

This is a problem, because the situation often arises where I developed some code for a client, and need to put the repo on their server without giving them write access to the github repo.

git clone https://github.com/user/repo.git

was throwing an error:

Error: The requested URL returned error: 403 while accessing # https://github.com/user/repo.git/info/refs # fatal: HTTP request failed 

From https://help.github.com/articles/https-cloning-errors it was determined that the git version installed via

yum install git

(1.7.1), didn't support cloning from https.

 

Solution

Needed to build git from source.

Here are the steps to successfully build git on Centos 6.2:

*All commands are ran as "root"

  1. Remove git if you have it installed from yum
    yum remove git

  2. Install the dependencies for build, and grab the git source code
    note: you will want to change the version number to whichever git version you want to install. I chose the latest git version at the time of this post, 1.8.1.1. You'll want at least 1.7.10 to clone from https://
    cd ~/
    yum install gcc make gcc-c++ zlib-devel perl-ExtUtils-Embed gettext curl-devel expat-devel
    wget http://git-core.googlecode.com/files/git-1.8.1.1.tar.gz
    tar -zxvf git-1.8.1.1.tar.gz 

  3. Build git
    cd git-1.8.1.1 && ./configure && make && make install
  4. Link it in /usr/bin
    ln -s /root/git-1.8.1.1/git /usr/bin/ 

     

You should be all set!

Comments

Ricardo (not verified)

Wed, 04/17/2013 - 23:02

Comment
Thanks a lot!