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.

What Is Git?

Git is a form of version control – a critical software configuration management tool. With the benefit of a version control system (VCS), you can track, annotate, and organize changes to documents, websites, computer programs, and many other kinds of collected information.

For software developers, a VCS allows source-level software management. It allows developers to track changes, revert to earlier versions, or divert from the base code and build new file versions and new directories.

Git is today’s most frequently installed VCS worldwide.

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

Installing GIT on CentOS 7 with Arrow and logo

Prerequisites

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!

2. 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.

verification of a successful installation of Git

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 groupinstall "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 installhttps://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

screenshot after removing a version of GIT

Conclusion

Your installation Git on CentOS 7 should be complete!

Git offers a leading-edge distributed VCS to facilitate collaboration by enabling all parties to annotate, manage, and track file edits.

Project participants may now upload and keep their files in GitHub repositories with remarkable ease.