DevOps

How to Install Git on CentOS 8

image 103 e1709045640608

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.

image 103 e1709045640608

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.

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"

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.

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

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 allmake 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
image 104

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.

Đăng ký liền tay Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !

Add Comment

Click here to post a comment

Đăng ký liền tay
Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !