Git released version 2.21 on Feb 24, 2019. This tutorial is for installing the latest version release of Git 2.21 on CentOS/RHEL 7/6.

 

Let’s walk through the process of installing Git on CentOS 7.

Prerequisites

  • A Linux-based system with a CentOS 7 installed
  • A non-root user account with sudo privileges

Tools/Software

  • Default package installer, Yum
  • CentOS development tools and default repositories

 

Option 1: Install Git with Yum

The easiest, fastest way to install Git is with Yum (Yellowdog Updater, Modified), CentOS’s package manager.

Follow these steps to install the latest version of Git on your CentOS 7 server.

  1. Find and install the latest version with the command:
yum install git

Now you’ve got Git and you’re ready to go!

  1. Verify the installation using the command:
git --version

The output should display the version number of Git that you have installed successfully.

For example: git version 2.21.0

Based on the output above, you have successfully installed Git version 2.21.0 on CentOS.

 

Option 2: Install Latest Version of Git From IUS Repository

If you are seeking a custom range of options, you may prefer to install Git from IUS, a community-run source of quality packages stored in the .rpm file format (RPM packages)

Inline with Upstream Stable (IUS) is a dynamic, community-run source of quality RPM packages. It provides updated versions of the key software for CentOS and Red Hat Enterprise Linux (RHEL).

Note: You can’t directly upgrade from stock packages to IUS packages.

 

Step 1: Install Development Tools

Go to your default repositories provided in CentOS, and retrieve the necessary tools to build a binary for the version of Git you plan to install.

You’ll enter:

sudo yum group install "Development Tools"

Then:

sudo yum install gettext-devel openssl-devel perl-CPAN perl-devel zlib-devel

 

Step 2: Installation From Source

Install CentOS 7 repo from IUS using the command:

sudo yum install https://centos7.iuscommunity.org/ius-release.rpm

Then:

sudo yum install git2u-all

 

Step 3: Verify Installation

Now, you should have the latest version.

Perform a version check for Git on your CentOS 7 server with the command:

git --version

This ensures you have successfully installed the desired version of Git onto the CentOS 7 server.

For example: git version 2.21.0

Based on the output above, you have successfully installed Git version 2.21.0 on CentOS 7.

 

Remove Previous Git version with Yum

To remove an old version of Git, use this command:

sudo yum remove git

Conclusion

Your installation Git on CentOS 7 should be complete!

The end!