How to Install Git on CentOS 7
3 min read
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
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.
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
sudo nano /etc/yum.repos.d/wandisco-git.repo/etc/yum.repos.d/wandisco-git.repo
[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
Once the repository is added, install the latest version of Git by running the following command:
sudo yum install git
To verify the installation type the command below which will print the Git version:
The output will look something like below, meaning that Git version 2.18.0 has been successfully installed on your CentOS system.
git version 2.18.0
Now 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:
git config --global user.name "Your Name"
git config --global user.email "email@example.com"
Use the following command to verify the changes:
git config --list
user.name=Your Name firstname.lastname@example.org
The configuration settings are stored in the
[user] name = Your Name email = email@example.com
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 feedback, leave a comment below.