How to Install Git on CentOS 8

January 14, 2020

Introduction

Git is a popular version control system that organizes the development cycle of an application. Git is used by developers to keep track of code changes, create branches, and collaborate within a software team.

This article will show you two options of how to install Git on CentOS 8.

tutorial on how to install Git on CentOS 8

Prerequisites

  • A Linux-based system with CentOS 8 installed
  • Access to the root user or an account with sudo privileges
  • DNF package manager (comes by default with CentOS 8)

Install Git on CentOS 8 from Local Repository

The easiest way to install Git is to download the package from your local repository. This installs the latest version of the software available on the CentOS repository.

1. Open a terminal window and update the repository with the command:

dnf update

2. Now, install Git with the command:

dnf install git

3. Verify the installation of Git on CentOS 8 by prompting for the version information:

git --version

The system should answer the query with the release number of the package as seen below.

command to check git version and output on Centos 8

Install Git on CentOS 8 from Source Code

Another way to install Git on CentOS 8 is directly from the source code. Doing so allows you to choose the Git version and/or download the latest release. You can also customize the build options to suit the needs of you and your team.

1. Before you download the Git package, install the required dependencies with the command:

dnf groupinstall "Development Tools"
install development tools for git

2. You also need to install libraries used for Git compilation:

dnf install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-CPAN perl-devel

3. Once you have all the necessary dependencies, navigate to the /usr/src directory where you want to download the source package:

cd /usr/src/

Depending on the version of Git you want to download, the URL in the following step will differ. Visit the official Git repository to see all of the available releases. Currently, v.2.24.0 is the latest master version and the one we are installing in this article.

git releases on gihub

4. For the latest stable version, copy the URL of the tar.gz file of v2.24.0 and paste it in the command:

wget https://github.com/git/git/archive/v2.24.0.tar.gz -O git.tar.gz
download Git on CentOS 8

5. Extract the tar package with:

tar -xf tir.tar.gz

6. Now compile Git and install it on your CentOS 8. Move to the git directory, compile, and install it with the following commands:

cd git-*
make prefix=/usr/local all
make prefix=/usr/local install

With this, you have finished the installation process.

7. As a final step, verify the installed Git version:

git --version

Set Up and Configure Git

Once you have installed Git, configure the software with your personal information. This info is displayed when generating commit messages.

To set up the name use the command:

git config --global user.name "Your Name"

Set up the email address with:

git config --global user.email "[email protected]"

Verify the configured information:

git config --list
configure Git with personal information

Conclusion

After reading this article, you should have installed and set up Git on CentOS 8, either from the local repository or the source code.

Download our Git Commands Cheat Sheet for free to have the most commonly used commands always at your hand.

Was this article helpful?
YesNo
Sofija Simic
Sofija Simic is an experienced Technical Writer. Alongside her educational background in teaching and writing, she has had a lifelong passion for information technology. She is committed to unscrambling confusing IT concepts and streamlining intricate software installations.
Next you should read
How to Install Git on CentOS 7 With Yum or Latest Repository
March 15, 2019

In this tutorial, learn how to install Git on CentOS 7. Git is a distributed version control system to track...
Read more
CentOS 8 Released: New Features, Changes, & How to Download
October 2, 2019

CentOS is widely popular among developers and system administrators as it offers full control over its highly...
Read more
How to Create a New Branch in Git
January 9, 2024

This article outlines the basic commands needed to create a Git branch. A Git branch allows you to work on ...
Read more
How To Rename a Local and Remote Git Branch
April 11, 2024

Git is a version control system that helps you control the stages of software development. It uses named...
Read more