Friday, November 15, 2024
Google search engine
HomeGuest BlogsHow to Install Git on CentOS 8

How to Install Git on CentOS 8

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 8tutorial 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 8command 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 gitinstall 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 gihubgit 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 8download 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 "your-email@email.com"

Verify the configured information:

git config --list
configure Git with personal informationconfigure 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

RELATED ARTICLES

Most Popular

Recent Comments