How to Install Git on CentOS 7 With Yum or Latest Repository

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.

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.

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

tutorial on centos install git on 7

Prerequisites

  • A Linux-based system with a CentOS 7 installed
  • A non-root user account with sudo privileges
  • 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

Let the system finish installing Git.

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.

install git on centos 7

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

Enter:

sudo yum groupinstall "Development Tools"

Then run this command:

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
remove previous git version

Conclusion

Your installation Git on CentOS 7 should be complete! If you are running a newer version of CentOS, check out our article on installing Git on CentOS 8.

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

For Ubuntu, see our guide on installing Git on Ubuntu.

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/222796.html

(0)
上一篇 2022年1月6日
下一篇 2022年1月6日

相关推荐

发表回复

登录后才能评论