How to install Git on Centos 8 by Yum Command and Source Code?

This article showed how to use yum command and source code to install Git on the Centos 8 server. Before show how to install Git on Centos 8, let’s introduce the Git tool.

What’s Git?

Git is a version control system, then what’s version control system?

Version control system tool is software that helps a group of software developers work together and manage their work history. It does not overwrite other people’s changes, so you can track each change and restore a file or project to its previous state.

Version control tools help you recover lost files with great ease. If anyone on the team makes an error, you can review and compare earlier versions of the file and fix the error or any conflicts.

Git is one of the most popular distributed revision control system tools that developers use to coordinate their work. It was designed by Linus Torvalds in 2005. Git provides features such as data assurance, workflow, branch creation, restore to the previous stage, incredible speed, tracking code changes, view logs, etc.

Git allows you to perform work in offline mode, and when you are ready, you need an Internet connection to publish changes and make the most recent changes.

In this article, we’ll show you how to use yum command and the source code to install Git on the Centos 8.

How use yum command to install Git on Centos 8?

Using package management system is one of the easiest and easiest ways to install Git, but the available versions may be older than the latest available versions.

If you want to install the latest version of Git, consider compiling from source code.

$ sudo yum install git

Once you have Git installed, you can verify the installed version of Git with the following command.

$ git --version

How to install Git from source code?

If you want to do this with a specific version of Git or need a flexible installation, one of the best ways to do this is to collect Git software from Source.

However, it does not manage and update Git installations via package management system, but will allow you to install the latest version of Git and customize build options. It’s a bit of a lengthy process. Before proceeding with the installation, you will need the following tools necessary to build the binary file from source code.

$ sudo yum groupinstall "Development Tools"
$ sudo yum install wget unzip gettext-devel openssl-devel perl-CPAN perl-devel zlib-devel libcurl-devel expat-devel

Once the tool is installed, open any browser and access the image of the Gits project on GitHub Release. At the top is the latest version of Git, but in the end it may be different.

Now, look at the version you want, right-click the source code (Tar. gz) , and copy the link to download using the following wget command, as shown below.

$ sudo wget -O git.tar.gz

When the download is completed, to unzip the source package using the tar command, and move it to that directory.

$ sudo tar -xf git.tar.gz
$ cd git-*

Now, to install and build Git from source using the following command.

$ sudo make prefix=/usr/local all install

After compiled the source code, you can type the following command to verify the installation of the Git version.

$ git --version

git version 2.23.0

How to configure Git?

Now, Git has been successfully installed on the CENTOS machine, you need to set up your personal information, which will be used when you make any changes to your code.

$ git config --global "W3Cgeek"
$ git config --global "[email protected]"

The above settings are stored in the global configuration ~ / . In the GITCONFIG file. To make any other changes to this file, use the Git config command or edit it manually.

That’s all. We have showed how to use Yum command to install Git on the Centos 8 server by compiling the source code.

Leave a Comment