Close this search box.

How to install Git on CentOS 7

Table of Contents

How to install Git on CentOS 7


Git (/ɡɪt/) is a distributed version control system for tracking changes in source code during software development. It is designed for coordinating work among programmers,

but it can be used to track changes in any set of files. Its goals include speed, data integrity, and support for distributed, non-linear workflows[clarification needed].

Install Git

The two most common ways to install Git will be described in this section. Each option has advantages and disadvantages, and your choice will depend on your needs. For example, users who want to maintain updates to the Git software will likely want to use yum to install Git,


while users who need features presented by a specific version of Git will want to build that version from the source.

Option One — Install Git with Yum
The easiest way to install Git and have it ready to use is to use CentOS’s default repositories. This is the fastest method, but the Git version installed this way may be older than the newest version. If you need the latest release, consider compiling Git from the source (the steps for this method can be found further down this tutorial).

Use yum, CentOS’s native package manager, to search for and install the latest git package available in CentOS’s repositories:

sudo yum install git

If the command completes without error, you will have Git downloaded and installed. To double-check that it is working correctly, try running Git’s built-in version check:

git --version

If that check produced a Git version number, you can now move on to Setting up Git, found further down this article.

Option Two — Install Git from Source

If you want to download the latest release of Git available or enjoy more flexibility in the installation process, the best method is to compile the software from the source. This takes longer and will not be updated and maintained through the yum package manager. Still, it will allow you to download a newer version than what is available through the CentOS repositories and give you some control over the options you can include.

Before you begin, you’ll need to install the software that Git depends on. These dependencies are all available in the default CentOS repositories, along with the tools that we need to build a binary from the source:

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

After you have installed the necessary dependencies, you can look up the version of Git that you want by visiting the project’s releases page on GitHub.

The version at the top of the list is the most recent release. If it does not have -rc (short for “Release Candidate”) in the name, it is a stable release and safe for use. Click on the version you want to download to be taken to that version’s release page.


Then right-click the Source code (tar.gz) button and copy the link to your clipboard.

Now we will use the wget command in our CentOS server to download the source archive from the link we copied, renaming it to git.tar.gz in the process so that it is easier to work with.

Note: the URL you copied may differ from mine since the release you downloaded may vary.

wget -O git.tar.gz

Once the download is complete, we can unpack the source archive using tar. We’ll need a few extra flags to ensure the unpacking is done correctly: z decompresses the library (since all .gz files are compressed), and x extracts the individual files and folders from the archive. F tells tar that we are declaring a filename to work with.

tar -zxf git.tar.gz

This will unpack the compressed source to a folder named after the version of Git that we downloaded (in this example, the performance is 2.1.2, so the folder is named git-2.1.2). We’ll need to move to that folder to begin configuring our build. Instead of bothering with the full version name in the folder, we can use a wildcard (*) to save us some trouble moving to that folder.

cd git-*

Once we are in the source folder, we can begin the source build process. This starts with pre-build checks for software dependencies and hardware configurations. We can check for everything we need with the configure script generated by make configure. This script will also use a –prefix to declare /usr/local (the default program folder for Linux platforms) as the appropriate destination for the new binary and will create a Makefile to be used in the following step.

make configure

./configure --prefix=/usr/local

Makefiles are scriptable configuration files that are processed by the make utility. Our Makefile will tell make how to compile a program and link it to our CentOS installation so that we can execute the program correctly. With a Makefile in place, we can now run make install (with sudo privileges) to compile the source code into a working program and install it to our server:

sudo make install

Git should now be built and installed on your CentOS 7 server. To double-check that it is working correctly, try running Git’s built-in version check:

git --version

If that check produced a Git version number, you could now move on to Setting up Git below.

Set Up Git

Now that you have Git installed, you must submit some information about yourself so that commit messages will be generated with the correct information attached. To do this, use the git config command to provide the name and email address that you would like to have embedded into your commits:

git config --global "Your Name"
git config --global "[email protected]"

To confirm that these configurations were added successfully, we can see all of the configuration items that have been set by typing:

git config --list Name
[email protected]

This configuration will save you the trouble of seeing an error message and revising commits after you submit them.

Tips and tricks

In this tutorial, you have successfully learned how to install Git on CentOS 7. If you want to learn more about it, check out these documents:

If you want a server with CentOS 7 operating system, get started now with VPSie and get one month for free.

This tutorial will help you based on this original tutorial; please use our tutorial for notes and tips.



Git is a distributed version control system that tracks source code changes during software development.

You can install Git on CentOS using the following steps:

  1. Open/start a terminal and run the following command to update your system’s package index: sudo yum update
  2. Run this command to install Git: sudo yum install Git
  3. confirm that Git has been installed by running the following command: Git –version
  4. This should display the version number of Git installed on your system.

Yes, you can install a specific version of Git on CentOS by specifying the version number in the command. For example, to install Git version 2.33.1, you would run the following command: sudo yum install git-2.33.1

You can check if Git is already installed on your CentOS system by running the following command: Git –version
If Git is installed, this command will display the version number of Git installed on your system.

Yes, Git could be used to manage source code for projects written in various languages, including Java, Python, Ruby, and many others.

You can uninstall Git from CentOS using the following command: sudo yum remove Git

After installing Git, you should configure your Git username and email address using the following commands: Git config –global user. Name “Your Name” git config –global “[email protected]

Replace “Your Name” and “[email protected]” with your actual name and email address.

Yes, Git is designed to facilitate collaboration on software development projects. You can use Git to share your code with other developers, review and merge changes, and track the history of your project.

Make a Comment
Share on
VPSie Cloud service

Fast and Secure Cloud VPS Service

For a month

The First 1 orders gets free discount today! Try Sign up on VPSie to get a chance to get the discount.