How To Install Git On CentOS 7

Git is a very useful version control tool in the today’s software development industry. I use it all the time so thought to write a useful tutorial for unixmen readers on how to install git on CentOS 7.

What is Git?

If you have ever used sites like Github or pushed code on Bitbucket to show it to your friends then you probably know what git is, at least it is for sure you have an idea about it.

Git is the most widely used version control system for software development which was initially released nine years ago on 7 April 2005 with the main primary goal of  maintaining a large distributed development project. Unlike client-server systems software developers are independent of network access or a central server as every Git working directory  is a full-fledged repository.

Linus Torvalds the author who started the development of Git decided to release it for free under the terms of the GNU General Public License version 2. According to wikipedia there are many languages being used to develop this version control system such as Perl, Bash, C and Tcl.

Before continuing with the installation of Git on GentOS version 7 I have to mention that it  Git supports the main operating systems such as Linux, POSIX, Windows and OS X.


Make sure you have CentOS 7 installed on your machine as well as an account with root privileges as it is needed to install software on your system.

Installing Git – Compiling from source

Compiling and installing software from source is not very hard, but for sure it requires some knowledge and I highly recommend to follow each instruction presented on this tutorial very carefully  especially if you have not done this before.

Installing Git from source will allow us to get the latest version where latest features are included but the disadvantage of this method is that once the installation is finished the yum package manager which is being used on CentOS systems can not be used to update on this piece of software.

There are some package dependencies that you have to install manually in order to continue with the installation so fire up a terminal on CentOS 7 and run the following commands.

Since all these dependencies are in the default repositories of CentOS 7 the yum package manager can be used to download an install them. The first one we need to install is the Development Tools.

Become root by running the following.

su root

Use the following command.

sudo yum install "Development Tools"

The above command did not work for me. If that’s the case for you too then use the following command to solve this problem.

yum  groupinstall "Development Tools"

Select y and hit Enter.

Then run the following command to install some other packages needed for the purpose of this tutorial.

sudo yum install gettext-devel openssl-devel perl-CPAN perl-devel zlib-devel

Once the dependencies have been installed then we need to find out and download the latest version of Git software. The following screenshot shows the page from where we will get it.

As you can see from the above screenshot the latest version is v2.3.0. Always make sure to download a version that does not have -rc in it as it stands for a release candidate.

Download version 2.3.0 of Git by using the wget utility.


Then use the tar utility to untar the .tar archive you just downloaded.

tar xvf v2.3.0.tar.gz


Then use the cd command to change the working directory like shown below.

cd git*


Once we are in the source folder we can start building. Run the following commands.

make configure
./configure --prefix=/usr/local

You will see something similar to what is shown in the following screenshot.

 We can now execute make install command to finally install the Git software on our CentOS machine.

make install

Be patient after running the above command as it will take some time for the installation to complete. To make sure Git is installed properly run the following command.

git --version

If the above command works then you have done it right.

Install Git – Using Package manager

The easiest way to install Git on CentOS is to use the yum package manager. The following command will help you to download the Git software on your system.

sudo yum install git