How to Install GIT on CentOS Stream EL9 or EL8

Git, a foundational tool in version control systems, allows developers to precisely track and manage software project modifications. For individuals looking to install Git on CentOS Stream 9 or the earlier enterprise-focused release, CentOS Stream 8, this introduction outlines its key benefits and standout features.

Key Attributes of Git:

  • Distributed Control: Git operates on a distributed version control model, enabling multiple developers to work concurrently without hindrance.
  • Efficient Branching & Merging: Facilitates creation, management, and seamless merging of multiple branches.
  • Staging Precision: Offers a dedicated staging area, ensuring commits are organized and intentional.
  • Comprehensive History: Maintains a thorough revision history, granting insights into every change.
  • Collaborative Prowess: Its distributed nature and support for various protocols, including HTTP, SSH, and Git, make collaboration effortless.
  • Versatility: Beyond CentOS Stream, Git is compatible with various platforms, from Windows and macOS to various Linux distributions.
  • File Extensiveness: With Git LFS, even large files are efficiently managed and tracked.

Embracing Git on CentOS Stream streamlines code management and fosters collaboration, ensuring every change is accounted for. Its robust features, from precise branching to comprehensive revision tracking, position it as an indispensable asset for developers. Dive into the subsequent sections to master the installation of Git on CentOS Stream, unlocking a world of streamlined software development.

Update CentOS Stream Before Git Installation

Ensuring System Packages are Up-to-Date

Before installing Git on CentOS Stream, it’s crucial to update the system. This process ensures that all packages currently installed on your system are the latest versions, providing both security and functionality improvements.

Executing the Update Command

To update your CentOS Stream system, use the following command:

sudo dnf upgrade --refresh

This command instructs the package manager (dnf) to upgrade all installed packages. The --refresh option forces the package manager to refresh the repository metadata, ensuring you receive the latest updates. It’s a vital step for maintaining system integrity and performance, especially before installing new software like Git.

Install GIT on CentOS Stream 9 or 8 via DNF

Step 1: Install GIT via DNF Command

To install Git on CentOS Stream, leverage the built-in package manager, a convenient tool for software management. The package manager simplifies the installation process, ensuring efficient and correct setup. Employ the following command to initiate the installation:

sudo dnf install git

This command directs the package manager to install Git, along with any necessary dependencies, streamlining the setup.

Step 2: Verify Installation of GIT

After installing Git, it’s essential to confirm that the installation was successful. To verify, execute the following command:

git --version

This command checks the installed version of Git, providing an immediate confirmation of a successful installation. A response with the Git version number indicates a successful setup.

Install GIT on CentOS Stream 9 or 8 via source

Step 1: Download Git Source Archive on CentOS Stream

To install Git from source, begin by identifying the latest stable version or a specific version you require. Access the Git tags release page on GitHub to find the most current stable release. Use the wget command to download the chosen version:

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

Replace vx.x.x with the version number you wish to download. For instance, if you’re targeting version 2.39.0, the command would be:

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

Always verify the version number, as software versions frequently update. Regularly check the release page to ensure you’re downloading the most recent version.

Extracting the GIT Source Code

After downloading the Git source archive, proceed to extract the contents:

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

Again, replace git-x.x.x.tar.gz with the actual file name of the downloaded source.

Navigating to the GIT Extracted Directory

Change into the directory of the extracted source:

cd git-x.x.x

Step 2: Preparing the Environment for Git Installation

Installing Development Tools

Before configuring Git, it’s advisable to install development tools that include most dependencies required for the build:

sudo dnf groupinstall "Development Tools"

Installing Additional Dependencies

Some dependencies might not be included in the development tools package. Install these additional libraries to ensure a smooth build process:

sudo dnf install libcurl-devel expat-devel

Step 3: Compiling and Installing Git

Compiling Git from Source

With all dependencies in place, compile Git using the make command:

sudo make prefix=/usr/local all

This command initiates the compilation process, preparing Git for installation.

Screenshot of precompile script for GIT on CentOS Stream el9 or el8.
A closer look at the precompilation process for GIT on CentOS Stream 9 or 8.

Installing the Compiled Git

Now install the compiled version of Git to your system:

sudo make prefix=/usr/local install
Screenshot of GIT post-compilation on CentOS Stream el9 or el8.
Proof of GIT’s seamless integration with CentOS Stream 9 or 8.

Step 3: Verifying Git Installation

After installation, confirm that Git is correctly installed:

git --version

This command checks and displays the installed version of Git, verifying a successful installation.

Conclusion

In this guide, we navigated through two effective methods to install Git on CentOS Stream: using the DNF package manager for a quick and straightforward installation, and compiling directly from the source code for more customization and access to specific versions. Whether you’re a seasoned developer or just starting out, these methods ensure you have Git set up efficiently on your system. Remember to regularly check for updates to maintain security and access new features.

Leave a Comment


Your Mastodon Instance
Share to...