Install GIT on Rocky Linux EL9 or EL8: Quick & Reliable Steps
If you’re still hunting around for a reliable way to get Git up and running on Rocky Linux 8 or 9, this guide covers the straight‑forward path plus a few tricks for when you need a newer version than what ships in the default repos. No fluff, just real-world steps that work.
1. Installing the Official Package
The simplest route is to pull the package straight from Rocky’s own repositories.
sudo dnf install git
Why this matters:
- The git package is already built and tested for your distribution version.
- Dependencies like libcurl, openssl-libs, and pcre2 are resolved automatically, so you avoid the “missing library” headaches that pop up when you try to compile from scratch on a fresh install.
After installation, verify:
git --version
You should see something along the lines of git version 2.26.1.el8 for EL8 or 2.34.1.el9 for EL9. Those are the stock releases that ship with the OS.
2. Common Pitfall: Broken SSL After a Curl Update
I once had a system where an accidental update of the curl package to 7.80 caused Git’s HTTPS operations to choke with “SSL certificate problem: unable to get local issuer certificate.” The culprit was the mismatch between Git’s bundled CA certificates and the new libcurl runtime.
Fix: Reinstall git after rolling back or updating the ca-certificates package:
sudo dnf reinstall git ca-certificates
Then run a quick test against a public repository to confirm SSL is happy again.
3. Want the Latest Git? Build From Source
If you’re working on cutting‑edge features that depend on Git 2.39+ (or just hate waiting for the next distro update), compiling from source gives you full control.
# Pull build dependencies
sudo dnf groupinstall "Development Tools" -y
sudo dnf install curl-devel expat-devel gettext-devel openssl-devel \
zlib-devel libcurl-devel pcre2-devel perl-ExtUtils-MakeMaker
# Get the latest tarball
cd /tmp
git clone https://github.com/git/git.git
cd git
git checkout v2.39.1 # or whatever is newest
# Build and install
make configure
./configure --prefix=/usr/local
make all
sudo make install
Why this matters:
- You get the absolute latest features (e.g., partial clone, improved performance).
- By installing into /usr/local, you avoid clashing with the system’s packaged Git.
Remember: When you compile from source, your $PATH might still point to the older /usr/bin/git. Add /usr/local/bin before it:
echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bashrc source ~/.bashrc
4. Quick Global Git Configuration
No matter which install method you choose, set your identity once so Git remembers who you are.
git config --global user.name "Your Name" git config --global user.email "you@example.com"
Now every commit will carry the correct author info.
5. Handy Tip: Checking for Updates
The distribution’s dnf can keep your Git up to date with OS releases:
sudo dnf update git
If you built from source, run the same git pull/make install cycle whenever a newer tag appears.
There you have it—Rocky Linux 8 or 9, Git installed and ready for action.