Tutorials  /  Linux Basics

Install and Configure Git on Rocky Linux 9 Guide

Ccentron Redaktion · August 2025 ·7 min read ·Linux Basics, Tutorial

Git is an open-source, distributed version control system that tracks file changes and enables efficient project management. It allows multiple collaborators to work on the same file, while preserving and monitoring the complete history of all changes in a repository. Git integrates seamlessly with repository hosting platforms like GitHub, GitLab, and BitBucket, making it easier to collaborate and maintain version control across projects.

This guide explains how to install Git on Rocky Linux 9. You will learn how to check the pre-installed Git version and install the latest stable version on your workstation.

Prerequisites

  • Access to a Rocky Linux 9 instance as a non-root user with sudo privileges.
VM

Matching infrastructure at centron

No hardware needed to follow along: ccloud³ VMs with full root access start at €3.12 per month, billed by the hour and ready in seconds. Rent a cloud server →

Check the Default Git Version

By default, Rocky Linux 9 comes with Git pre-installed. Although the included version might not be the latest, it is sufficient for performing version control tasks and managing repositories locally. Follow the steps below to verify your current Git version before upgrading or installing a specific version.

Check the pre-installed Git version:

Console
$ git --version

Example output:

git version 2.43.5

Run the Git help command to confirm you can access all available options:

Console
$ git help

Install Git Using DNF

Dandified YUM (DNF) is the default package manager on Rocky Linux 9, allowing you to install packages from its repositories. While the version available in DNF may not be the latest, it provides a quick way to install a stable release of Git.

First, update the package index:

Console
$ sudo dnf update

Then, install Git:

Console
$ sudo dnf install git

If the following message appears, it means the latest stable version from the Rocky Linux 9 repository is already installed:

Package git-2.43.5-2.el8_10.x86_64 is already installed.

Dependencies resolved.

Nothing to do.

Complete!

Verify the installed Git version:

Console
$ git -v

Install a Specific Git Version from Source

Building Git from source gives you the flexibility to install the latest release or a specific version required by your project. This method also allows installing beta or alpha versions not available in DNF repositories.

First, update the package index:

Console
$ sudo dnf update

Install dependencies required for compiling Git:

Console
$ sudo dnf install gettext-devel openssl-devel perl-CPAN perl-devel zlib-devel gcc autoconf libcurl-devel expat-devel

Download the desired Git version from the official archives (e.g., version 2.49.0):

Console
$ wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.49.0.tar.gz

Extract the downloaded archive:

Console
$ tar -xvf git-2.49.0.tar.gz

Enter the extracted directory:

Console
$ cd git-2.49.0

Compile Git and install it into /usr/local:

Console
$ sudo make prefix=/usr/local all

Install the compiled Git package:

Console
$ sudo make prefix=/usr/local install

Open a new shell session to apply the changes:

Console
$ bash

Check the installed version:

Console
$ git --version

Configure Git

Before using Git, configure your username and email, as these details are included in commit messages.

Set your global username:

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

Set your global email:

Console
$ git config --global user.email "email@example.com"

To set username and email for a single repository, omit --global:

Console
$ git config user.name "Your Name"
$ git config user.email "email@example.com"

View your Git configuration:

Console
$ git config --list

Open the global configuration file:

Console
$ nano ~/.gitconfig

Edit the local repository configuration file if applicable:

Console
$ nano .git/config

Example configuration format:

Code
[user]
    name = Your Full Name
    email = email@example.com

Save changes and exit the editor to apply your updates.

Access and Use Git

With Git installed and activated on your Rocky Linux 9 system, you can now integrate it into your project workflow. The steps below demonstrate how to set up a local project, manage files, and authenticate with a remote repository service such as GitHub for committing changes.

Create a new project directory:

Console
$ mkdir git-project

Navigate into the project directory:

Console
$ cd git-project

Create a sample file, for example bash-script.sh:

Console
$ touch bash-script.sh

Initialize the directory as a Git repository:

Console
$ git init

Example output:

hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint:   git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint:   git branch -m <name>

Stage all files in the directory:

Console
$ git add .

Stage a specific file instead of all files:

Console
$ git add <filename>

Commit the staged changes with a message:

Console
$ git commit -m "new commit"

Add a remote repository to connect with your local repository:

Console
$ git remote add origin <remote repository>

Set the remote URL with authentication details for GitHub (or another provider):

Console
$ git remote set-url origin https://<username>:<token>@github.com/username/repo.git

Push changes from the local repository to the main branch of the remote repository:

Console
$ git push origin main

Retrieve the latest changes from the remote repository:

Console
$ git pull origin main

View the commit history of the repository:

Console
$ git log

List all remote repositories linked to your local repository:

Console
$ git remote

List all branches, including local and remote branches:

Console
$ git branch -a

Conclusion

You have successfully installed Git on Rocky Linux 9, set up and configured local repositories, and learned how to synchronize changes with a remote repository. Git enables robust version control, making it possible to track, manage, and roll back file changes as needed. By integrating Git with a service like GitHub, you can securely store your repository online and collaborate effectively. For further details, refer to the official Git documentation.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Linux Basics
Teilen
Noch offene Fragen?

Unser Team hilft Ihnen bei Ihrem konkreten Setup weiter – von Menschen, die die Plattform selbst betreiben.

War dieses Tutorial hilfreich?

Ihre Antwort wird anonym gespeichert und hilft uns, die Tutorials zu verbessern.

Kommentare

Noch keine Kommentare – stellen Sie die erste Frage zu diesem Tutorial.

Zum Kommentieren anmelden

Kommentare stehen centron-Kunden offen. Melden Sie sich in Ihrem Konto an, um eine Frage zu diesem Tutorial zu stellen.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren