How to Install Git on CentOS 7

This tutorial will walk you through the installation and basic configuration of Git on CentOS 7.
Git is the most popular version control system that’s being used by hundreds of thousands of projects. Git allows you to keep track of your code changes, revert to previous stages, work simultaneously on multiple branches, and collaborate with your fellow developers.
Git is originally developed by Linus Torvalds , the creator of the Linux kernel.
At the time of writing this article, the current version of Git available in the default CentOS 7 repositories is 1.8.3, which is pretty outdated.
The easiest way to install the most recent version of Git (v2.18) is to install it using the yum package management tool from the Wandisco
repositories.
Another option is to compile Git from the source which allows you to install the latest Git release and customize the build options. However, you won’t be able to update your Git installation through the yum package manager.
Prerequisites
Before continuing with this tutorial, make sure you are logged in as root or a user with sudo privileges .
Installing Git on CentOS 7
Follow these steps to install the latest Git version on your CentOS 7 system:
The first step is to enable the Wandisco GIT repository. To do that, open your text editor and create a new YUM repository configuration file named
wandisco-git.repoin the/etc/yum.repos.d/directory:Terminalsudo nano /etc/yum.repos.d/wandisco-git.repo/etc/yum.repos.d/wandisco-git.repoini[wandisco-git] name=Wandisco GIT Repository baseurl=https://opensource.wandisco.com/centos/7/git/$basearch/ enabled=1 gpgcheck=1 gpgkey=https://opensource.wandisco.com/RPM-GPG-KEY-WANdiscoImport the repository GPG keys with:
Terminalsudo rpm --import https://opensource.wandisco.com/RPM-GPG-KEY-WANdiscoOnce the repository is added, install the latest version of Git by running the following command:
Terminalsudo yum install gitTo verify the installation type the command below which will print the Git version:
Terminalgit --versionThe output will look something like below, meaning that Git version 2.18.0 has been successfully installed on your CentOS system.
outputgit version 2.18.0Now that you have Git installed it is a good idea to set up your personal information that will be used when you commit changes to your code.
To set your git commit username and email address type:
Terminalgit config --global user.name "Your Name" git config --global user.email "youremail@yourdomain.com"Use the following command to verify the changes:
Terminalgit config --listoutputuser.name=Your Name user.email=youremail@yourdomain.comThe configuration settings are stored in the
~/.gitconfigfile:~/.gitconfigconf[user] name = Your Name email = youremail@yourdomain.comTo make further changes to your Git configuration, you can either use the
git configcommand or edit the~/.gitconfigfile by hand. For more options, see our guide on configuring Git username and email .
Conclusion
We have shown you how to install Git on your CentOS 7 machine. You should now visit the online version of the Pro Git book and learn more about how to use Git.
If you hit a problem or have feedback, leave a comment below.
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page