Git is a free and open source distributed version control system, that is designed to handle any project; from small to very large projects with speed, data integrity and efficiency.In this tutorial, I’m going to show you how-to install Git on CentOS7, using Yum and from the source.
I’ll be using a 512 MB VPS from Digital Ocean. It’s only $5 per month and CentOS 7 is pre-installed!
Install Git Using Yum
First, we will make sure existing packages are up-to-date before we install Git:
sudo yum -y update
Next, we will install Git using Yum:
sudo yum install git
As always, we should confirm what we installed is actually installed. Check to see if Git is installed by running the following command:
You should see something like this:
git version 184.108.40.206
You are now done installing Git with Yum on CentOS 7.
Install Git From Source
In this part of the tutorial, I’m going to show you how-to install Git from source.
Again, we will firstly make sure existing packages are up-to-date:
sudo yum -y update
We will now install Git dependencies:
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-ExtUtils-MakeMaker asciidoc xmlto
Next, we will download the current latest version of Git:
You can always get the latest version of Git here.
Now we’ll unpack the tar archive file:
tar -zxf git-2.2.2.tar.gz
Next we will change to the directory:
Remember, if you are using a different version of Git, you will need to change the
2.2.2 part of the above three (3) commands.
We will now generate the configure script:
If you get an error like so:
/bin/sh: autoconf: command not found
You will need to run the following command and then the
make configure command:
sudo yum install autoconf
If you are successful, you will get
GEN configure. Now we will create the
If you get an error stating that no acceptable C compiler can be found. Run the following command and then run the above command:
yum groupinstall "Development tools"
We will now run the following command:
make all doc info
We will now compile the source code into a working program and install it:
sudo make install install-doc install-html install-info
After you’ve installed Git, we will setup Git:
git config --global user.name "Your Name"
You name should be replaced with your name.
git config --global user.email "firstname.lastname@example.org"
email@example.com should be replaced with your e-mail address.
Run the following command to check what you just set as your name and e-mail:
git config --list
You should see something like this (replaced with the info you’ve entered):
user.name=Your Name firstname.lastname@example.org
A Quick Git Test
Let’s do a quick test by cloning a git repository:
git clone https://github.com/brandonhimpfen/HTML-Template
You’ve just cloned my awesome HTML Template git repository. HTML Template is a professional, SEO optimized, HTML5 ready front-end template.