Read in 3 minutes
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 source which will allow you to install the latest Git version and to customize the build options, but you will not be able to maintain your Git installation through the
yum package manager.
Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges.
Installing Git on CentOS 7
Follow this steps to install the latest Git version on your CentOS 7 system:
Enable the Wandisco GIT Repository
To enable the Wandisco GIT repository open your text editor and create a new YUM repository configuration file named
[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
Import the repository GPG keys with:
sudo rpm --import http://opensource.wandisco.com/RPM-GPG-KEY-WANdisco
Installing Git on CentOS
Once the repository is added, to install the latest version of Git run the following command:
sudo yum install git
To verify the installation type the following command which will print the Git version:
git version 2.18.0
As you can see from the output above we have successfully installed Git version 2.18.0 on our CentOS system.
Now that you have Git installed it is good idea to set up your personal information that will be used when you commit changes to your code:
git config --global user.name "Your Name" git config --global user.email "[email protected]"
Use the following command to verify the configuration changes:
git config --list
user.name=Your Name [email protected]
The configuration settings are stored in the
[user] name = Your Name email = you[email protected]
To make further changes to your Git configuration, you can either use the
git configcommand or edit the
~/.gitconfigfile by hand.
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 a feedback, leave a comment below.