How to Install Git on CentOS Stream EL9 or EL8


Git is a widely-used version control system that tracks software development project changes. It allows multiple developers to work on a project simultaneously while keeping a record of all changes made to the code. Incorporating Git into your daily CentOS Stream desktop can bring many benefits, including collaborating with other developers, keeping track of changes made to your code, and quickly reverting to previous versions of your code.

List of Git features:

  1. Distributed version control
  2. Branching and merging
  3. Staging area for commits
  4. Ability to create and manage multiple branches
  5. Full revision history
  6. Support for distributed teams
  7. Ability to rollback to previous versions
  8. Support for multiple protocols, including HTTP, SSH, and Git
  9. Extensive file support with Git LFS
  10. Support for various platforms, including Windows, Linux, and macOS

In summary, Git is a powerful version control system that can benefit your daily CentOS Stream desktop. It allows for collaboration and easy management of changes to your code. Git’s features, such as branching, merging, and the ability to revert to previous versions, make it an essential tool for software development projects. Additionally, its support for multiple platforms and protocols makes it accessible to many users. The following guide will cover installing Git on your CentOS Stream distribution.

Update CentOS Stream

First, update your system to ensure that all existing packages are up-to-date.

sudo dnf upgrade --refresh

Method 1: Using the DNF Package Manager

The first method to install Git on CentOS Stream is by using the package manager. A package manager is a built-in tool with CentOS Stream that allows you to install and manage software packages quickly. To install Git using the package manager, use the following command.

sudo dnf install git -y

This command will install Git and all of its dependencies on your system.

Method 2: Compiling from Source

The second method to install Git on CentOS Stream is compiling it from the source code. This method is helpful if you need a specific version of Git unavailable in the package manager or if you want to install Git with custom configurations.

First, visit the release page to find the latest stable version or a particular version you are after. Then download it using the wget command.

Example only:

wget https://github.com/git/git/archive/refs/tags/vx.x.x.tar.gz

At the time of this tutorial, 2.39.0 was the latest, but this will change in time, so please ensure you grab the latest link and regularly check back to keep running the same method to update your GIT version.

wget https://github.com/git/git/archive/refs/tags/v2.39.0.tar.gz

Run the following command that will extract the source code.

tar -xzf git-x.x.x.tar.gz

Navigate to the directory.

cd git-x.x.x

First, I would advise to install the development tools, which will install nearly all required dependecies.

sudo dnf groupinstall "Development Tools"

Lastly, a few extra ones not covered in the development tools pack are required, run this command to install them.

sudo dnf install libcurl-devel expat-devel

Now run the make command to configure the script.

sudo make prefix=/usr/local all

Example output if successful:

example on precompile script for git on centos stream el9 or el8Pin

Next, install Git.

sudo make prefix=/usr/local install

Example output if successful:

Optionally, you can run Git in the terminal as well like seen above that should print out the version of Git you installed. Congratulations, you have compiled Git.

Conclusion

In this article, we have discussed the two ways to install Git on CentOS Stream using the command-line terminal. The first method is using the package manager, which is the easiest and quickest way to install Git. The second method is compiling from source, which is useful if you need a specific version of Git or want to install Git with custom configurations. Whichever method you choose, Git is a powerful version control system that can bring many benefits to your software development projects.

See also
How to Create a Python Virtual Environment on Ubuntu 22.04 or 20.04

Leave a Comment

Share to...