You don’t get surprised when you see that your CentOS, Ubuntu or another server already has Git installed. However, the default Git version that comes with the OS bundle is usually v1.7.1 and this might be a problem when you want to install applications which require higher Git versions(For example, Gitlab).
This article contains the steps that I followed while installing(or upgrading to) Git 220.127.116.11 to a CentOS 6.4 server.
First of all, make sure if you have git installed:
This has to return a value like “/usr/local/bin/git”. If it doesn’t, than you don’t have Git installed on your machine.
If it does return a path, than you better know which version, by using this command:
The result should be like: “git version 1.7.1”. If it returns the number equals or higher than the version you want to install, well, you got lucky. The day is over for you.
OK, let’s begin with a new installation.
1. Go to /tmp folder:
(Those who have older version of Git installed may go to step 3.)
2. Install default version of Git and maker for installing git:
yum -y install git perl-ExtUtils-MakeMaker
3. Clone git repo to your /tmp folder:
git clone git://github.com/git/git.git
4. Get inside of the repo and checkout your favorite version. I chose v18.104.22.168, you may choose something else.
cd /tmp/git/ git checkout v22.214.171.124
5. Continue preparing installation:
autoconf ./configure --prefix=/usr/local
IMPORTANT: You might have got an error like “-bash: ./configure: Permission denied”. If you haven’t, continue with step 7. If you have, no need to worry, we’ll fix it by using these commands:
6. Fix “Permission denied” error if exist
mount -o remount,exec,suid /tmp mount -o remount,exec,suid /var/tmp
7. Do it
make && make install
rm -rf /tmp/git/
9. Verify your installation:
(Should return Git path like “/usr/local/bin/git”)
10. Verify your version
(Should return your version, like: “git version 126.96.36.199”)
You may find most of the steps above in various websites, however it really took me a while to find out how to fix the permission error which I declared in step 6.
Fair enough, let’s go make some fork!