How to Downgrade Git Version on Linux

While Git frequently releases new versions with enhanced features and fixes, sometimes a project or environment may require an older version for compatibility. If you find yourself needing to downgrade Git, follow this step-by-step guide.


⚠️ Warning

Downgrading software can introduce security or compatibility risks. Only downgrade Git if you have a specific need, such as:

  • Compatibility with a CI/CD pipeline
  • Working with legacy projects
  • Resolving issues introduced in newer Git versions

✅ Step-by-Step: Downgrading Git on Ubuntu/Debian

🔹 Step 1: Uninstall the Current Version of Git

First, remove the currently installed version:

sudo apt remove git

This removes Git but does not delete your local repositories.


🔹 Step 2: Add the Older Git Version Manually

You have two main options for installing an older version:


Option A: Use apt with a Specific Version (if available)

  1. Check available versions:
apt list -a git
  1. Install a specific version:
sudo apt install git=1:2.25.1-1ubuntu3

Replace 1:2.25.1-1ubuntu3 with the version you want from the list.


Option B: Install from Source (More Flexible)

  1. Install required dependencies:
sudo apt update
sudo apt install -y make libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip
  1. Download the desired Git version:
wget https://github.com/git/git/archive/refs/tags/v2.34.1.zip
unzip v2.34.1.zip
cd git-2.34.1
  1. Compile and install Git:
make prefix=/usr/local all
sudo make prefix=/usr/local install
  1. Verify the installed version:
git --version

🔁 Optional: Pin the Version to Prevent Auto-Update

To prevent Git from being upgraded automatically:

sudo apt-mark hold git

To allow updates again later:

sudo apt-mark unhold git

✅ Summary

TaskCommand/Tool
Remove current Gitsudo apt remove git
Install older Git via APTsudo apt install git=<version>
Build Git from sourceDownload, make, and make install
Prevent auto-updatesudo apt-mark hold git

🚀 Final Thoughts

Downgrading Git is simple but requires care. If you’re managing a production system or collaborating with a team, ensure the change is communicated and tested. When possible, upgrade your tooling to work with the latest Git for long-term stability and security.

Sharing Is Caring:

Leave a Comment