Guides 11792 Published by

This guide walks Rocky Linux 8 users through installing Git quickly, whether they prefer the stable package from DNF or the latest build pulled directly from the project’s repository. It begins by checking for an existing Git binary and then shows how to install the official 2.34 release with a single `dnf` command, followed by a simple version check to confirm success. For those who need newer features such as `git switch`, it explains compiling from source after installing development tools, then covers setting global user identity and generating SSH keys for secure pushes to services like GitHub or GitLab. Finally, the article lists common pitfalls, offers handy command‑line fixes, and reminds users that routine `dnf update` keeps the packaged version patched while a manually compiled install must be updated by repeating the build steps.



Install Git on Rocky Linux 8: A Straight‑Forward Guide

If you’re running Rocky Linux 8 and the next thing you want is a version control system that actually works out of the box, this will get you there in minutes. We’ll cover the official package, a quick way to pull the latest release from the Git project, and a couple of tweaks that usually save headaches later.

1. Check What’s Already Installed
git --version || echo "Git not found"

If you’ve already got an older version (or none at all), this tells you what to upgrade or install. In my own lab, a stray `sudo yum remove git-core` left the machine with a 1.7 binary that broke every CI job.

2. Install the Official Rocky Package

Rocky Linux ships Git in its default repositories. Just run:

sudo dnf install -y git

The `-y` flag skips the confirmation prompt, which is handy for scripts. DNF pulls a stable 2.34 release that matches the system’s security updates.

If you prefer to double‑check what will be installed before the transaction starts, drop the `-y` and let DNF list the packages:

sudo dnf install git
3. Verify Installation
git --version

You should see something like `git version 2.34.x`. If you get an error, the package didn’t pull correctly—try removing it first.

sudo dnf remove git && sudo dnf install -y git
4. (Optional) Get the Latest Git from Source

Sometimes the distro’s version is a few releases behind, and you need newer features such as `git switch` or improved merge strategies. Compiling from source guarantees the latest build.

sudo dnf groupinstall -y "Development Tools"   # GCC, make, etc.
sudo dnf install -y curl openssl-devel zlib-devel

curl -L https://github.com/git/git/archive/refs/tags/v2.41.0.tar.gz | tar xz
cd git-2.41.0

make configure
./configure --prefix=/usr/local
make all doc info
sudo make install

Why compile? A newer Git can fix bugs that the packaged one hasn’t yet addressed, and it’s a good sanity check to see whether your system has all its build dependencies.

5. Configure Your Identity

Git won’t let you push commits without a name and email:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

Set these once, and Git remembers them for every repo you touch.

6. Optional: Set Up SSH Keys for Remote Repositories

If you’ll be pushing to GitHub or GitLab, SSH is the safest route:

ssh-keygen -t ed25519 -C "you@example.com"
cat ~/.ssh/id_ed25519.pub | pbcopy   # copy to clipboard

Add that public key to your remote account and test:

ssh -T git@github.com

You should see a welcome message instead of “Permission denied.”

7. Troubleshooting Common Pitfalls
Symptom Fix
`git: command not found` after installing Make sure `/usr/bin` is in your `$PATH`.
Remote rejects push with “fatal: Authentication failed” Verify the SSH key is on the server and you’re using the correct remote URL.
Git hangs during a large clone Disable the built‑in `progress` output: `git -c core.progress=false clone …`

I ran into the last one when cloning a 30 GB repo over a spotty VPN; turning off progress made it feel snappier.

8. Keep Git Updated

Rocky’s regular updates will keep Git patched:

sudo dnf update -y git

If you built from source, remember that `dnf` won’t know about your custom install, so pull a newer tarball and repeat the compile steps when you want to upgrade.

That’s all. You’ve got a working Git installation on Rocky Linux 8, ready for everyday work or advanced version‑control projects. If anything feels off, check the logs, read the error messages—Git usually tells you what went wrong.