Guides 11792 Published by

After a fresh Rocky Linux 9 installation the first thing most users want to do is get Git up and running, so this guide walks you through installing the official package from the BaseOS repository with just a few terminal commands. The instructions start by updating DNF’s cache, then install git‑y to skip prompts and keep dependencies minimal; the result is a stable, current build that won’t bloat your system. Next you verify the installation with `git --version` and troubleshoot common issues such as missing PATH entries or permission errors when using sudo on non‑root accounts, while also warning against pulling an older Git from EPEL that lacks modern helpers. Finally, if you need cutting‑edge features you can optionally upgrade via Software Collections or build from source, but remember that this shifts update responsibility onto you—otherwise the single dnf command keeps Git ready for action.



Install GIT on Rocky Linux 9 – Quick, Clean, and Ready for Action

When you’ve just pulled a fresh Rocky Linux 9 install, the next thing on your to‑do list is usually “get Git working.” This guide will walk you through installing the official package from the BaseOS repo, double‑checking that it’s functional, and fixing two common hiccups I’ve seen people run into.

Install Git with DNF

1. Open a terminal (or log in as root).

If you’re not already root, prepend each command with sudo. You’ll only be prompted once per session.

2. Update the package index:

   sudo dnf makecache

This ensures DNF knows about the latest version of Git available in Rocky’s repositories.

3. Install Git:

   sudo dnf install git -y

The -y flag skips the confirmation prompt, which is handy when you’re scripting or just want to get moving fast. The package pulls in a small set of dependencies—nothing that will bloat your system.

Why this matters: Rocky’s BaseOS repo ships with a stable, up‑to‑date Git build. Skipping extra repositories keeps the installation lean and reduces the risk of dependency conflicts.

Verify the Installation

Run:

git --version

You should see something like git version 2.42.x. If you get an error saying “command not found,” double‑check that your shell’s $PATH includes /usr/bin. Restarting the terminal is usually enough to refresh it.

Common Pitfalls
  • Using a non‑root user with missing permissions:

I’ve seen folks try sudo git config --global ... and hit “permission denied” on the global config file because they weren’t actually root when they ran the command. Either use sudo for every Git command that touches system files, or switch to the target user before you start configuring.

  • Old Git from EPEL vs. BaseOS:

On CentOS‑derived systems, people sometimes enable EPEL and install an older Git version that lacks modern authentication helpers (like GPG signing). Stick with the BaseOS package unless you have a compelling reason to build from source.

Upgrade Git (Optional)

If you need a newer feature or just want the bleeding‑edge bug fixes, consider installing via the Software Collections (SCL) or building from source. The process is a bit more involved but keeps your system clean:

sudo dnf install @development-tools
git clone https://github.com/git/git.git
cd git
make configure && ./configure --prefix=/usr/local
make -j$(nproc)
sudo make install

Why this matters: Building from source gives you the latest features and patches, but it also means you’re responsible for updates. If that’s not your style, stick with the package manager.

That’s all there is to it—Git on Rocky Linux 9 is a single command away. Grab your code, commit often, and enjoy a painless workflow.