Install and Upgrade GIT on Ubuntu 22.04 LTS
The goal is clear: get the newest Git on a fresh 22.04 system or bump an older installation to version 2.40+.
On a clean install the default Ubuntu repository ships with 2.30, which misses handy shortcuts like git switch. Below are the exact steps and why each one matters.
Check What’s Already There
git --version
If that prints git version 2.30.x, you’re stuck in the past. Knowing the current version lets you decide whether you really need to upgrade or can just keep using it.
Remove Any Broken or Partial Installations
sudo apt remove --purge git
Sometimes an interrupted apt install git leaves stale configuration files that block a clean fresh install. Removing the package entirely eliminates those ghosts.
Afterward, run:
sudo apt autoremove
to tidy up orphaned dependencies.
Add the Official Git Maintainers’ PPA
sudo add-apt-repository ppa:git-core/ppa
The Ubuntu repositories lag behind the upstream releases. The ppa:git-core PPA keeps pace with every minor update, so you get bug fixes and new features sooner.
Why a PPA? Because it’s officially maintained by the Git project itself, not some random third‑party.
Refresh Package Lists and Upgrade
sudo apt update
sudo apt install git
apt update pulls the newest metadata from the PPA; otherwise you’d still see 2.30.
Installing after adding the PPA gives you a clean, reproducible Git installation that matches the version you expect.
Confirm You’re on the Latest Version
git --version
You should now see something like git version 2.40.x. That means all the modern commands (switch, rebase --interactive, etc.) are available out of the box.
Real‑world tip: A few months ago I upgraded a colleague’s workstation from 20.04 to 22.04, and their Git was still stuck at 2.30. They kept running into errors when trying to use git switch. Adding the PPA fixed it in under ten minutes—no extra hassle.
Enjoy your new Git! If you run into any hiccups, double‑check that the PPA is listed with:
apt policy git
That will show which repository is providing the package and its version.