Home  »  ArticlesGuidesHardwareLibrariesProgrammingSoftwareTechnologyTools   »   How to Install Git on Rocky Linux 8.10 Systems

How to Install Git on Rocky Linux 8.10 Systems

Git is a widely-used version control system that allows developers to track changes in their codebase, collaborate with others, and manage project history efficiently. This guide will walk you through the steps to install Git on Rocky Linux 8.10.

Prerequisites

Before you begin, ensure you have:

  • A running Rocky Linux 8.10 system
  • A user account with sudo privileges
  • Internet connectivity to download packages

Step 1: Update Your System

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

$ sudo dnf update -y

Step 2: Install Git from the Default Repositories

Rocky Linux 8.10 comes with Git in its default repositories. The simplest way to install Git is to use the dnf package manager.

$ sudo dnf install git -y

Step 3: Verify the Installation

To verify that Git has been installed correctly, check the version of Git installed.

$ git --version

You should see output similar to:

$ git version 2.27.0

Step 4: Configure Git

After installing Git, it’s important to configure your Git environment. The minimum configuration includes setting your user name and email address, which will be associated with your commits.

Set Your Username

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

Set Your Email

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

Verify the Configuration

To verify your configuration settings, use:

$ git config --list

You should see something like:

user.name=Your Name
[email protected]

Step 5: Advanced Configuration (Optional)

Git has many configuration options that you can set to tailor it to your workflow. Some common configurations include setting the default text editor and enabling color output.

Set the Default Text Editor

By default, Git uses the system’s default text editor. You can set a different text editor if you prefer.

$ git config --global core.editor nano

Replace nano with your preferred text editor, such as vim, emacs, or code (for Visual Studio Code).

Enable Color Output

To make Git output more readable, you can enable color output.

$ git config --global color.ui auto

Step 6: Install Git from Source (Optional)

If you need a more recent version of Git than what is available in the default repositories, you can install Git from source.

Install Dependencies

First, install the necessary dependencies for building Git from source.

$ sudo dnf install -y wget tar curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker

Download the Source Code

Download the latest Git source code from the official Git website.

$ cd /usr/src
$ sudo wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.31.1.tar.gz

Extract the Tarball

Extract the downloaded tarball.

$ sudo tar xzf git-2.31.1.tar.gz
$ cd git-2.31.1

Compile and Install Git

Compile and install Git by running the following commands:

$ sudo make prefix=/usr/local all
$ sudo make prefix=/usr/local install

Verify the Installation

Check the version to verify that the installation was successful.

$ /usr/local/bin/git --version

Conclusion

You have successfully installed and configured Git on your Rocky Linux 8.10 system. Git is now ready to help you manage your projects and collaborate with others efficiently. For more detailed configurations and advanced usage, refer to the official Git documentation.

References

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.