;

How to install Git on CentOS 7

Try it in our public cloud & Get $5 Credit
CLAIM NOW
How to install GIT on CentOS 7

Git is a distributed version control system created by Linus Torvalds to develop Linux Kernel. A version control system allows us to save snapshots of a software project we are working on. Learn how to Install Git On CentOS 7.

The purpose of Git is to manage a project and set of files as they change over time. Git stores this information in a repository. A repository contains all of the project files and the entire revision history. Git allows multiple developers to work on the same project and allows you to keep track of changes, revert to the previous version and collaborate with other developers.

Prerequisite

  • A server running CentOS 7
  • ROOT access to the server

Install Git with Yum

The simple and easiest way to install Git is to use CentOS’s yum repository. By default, the latest version of the Git is not available in the CentOS 7 repository. So you will need to add the Wandisco repository in your system.

You can create it with the following command:

nano /etc/yum.repos.d/git.repo

Add the following lines:

 [wandisco-git]
 name=Wandisco GIT Repository
 baseurl=http://opensource.wandisco.com/centos/7/git/$basearch/
 enabled=1
 gpgcheck=1
 gpgkey=http://opensource.wandisco.com/RPM-GPG-KEY-WANdisco

Save and close the file when you are finished. Then, import the GPG keys with the following command:

rpm --import http://opensource.wandisco.com/RPM-GPG-KEY-WANdisco

Once the repository has been created, install the Git using the following command:

yum install git -y

Once the Git has been installed, verify the installed version of the Git using the following command:

git --version

You should see the following output:

git version 2.22.0


Install Git from Source on Centos 7

If you want to install the specific version of Git, it is a good idea to compile it from the source.

In order to compile the Git from the source, you will need to install the required dependencies in your system.

You can install all the required dependencies using the following command:

yum groupinstall "Development Tools
yum install gettext-devel openssl-devel perl-devel perl-CPAN zlib-devel

Once all the packages are installed, go to the Git release page. https://github.com/git/git/releases and download your desired Git version:

wget https://github.com/git/git/archive/v2.26.2.tar.gz

Once the download is completed, extract the downloaded file with the following command:

tar -xvzf v2.26.2.tar.gz

Next, change the directory to the extracted directory and create a Makefile and configure Git with the following command:

cd git-2.26.2
make configure
./configure --prefix=/usr/local

Next, run the following command to compile the Git and install it to your server with the following command:

make install

Once the Git has been installed, verify the installed version of the Git using the following command:

git --version

You should see the following output:

 git version 2.22.0


Configure Git

At this point, Git is installed in your system. Next, you will need to set up your personal information that will be used when you commit changes to your code.

You can set Git username and email address with the following command:

git config --global user.name "GloboTech Communications"
git config --global user.email "sysadmin@globo.tech"

You can verify the configuration using the following command:

git config --list

You should see the following output:

 user.name=GloboTech Communications
 user.email=sysadmin@globo.tech


Conclusion

In this guide, you learned how to install and configure Git on CentOS 7. For more information about Git, visit the Git documentation. https://git-scm.com/book/en/v2