How to Install the Latest Git on Ubuntu

Ubuntu’s default repositories often ship an older version of Git. If you need features like improved performance on large repos, better security patches, or newer commands, you’ll want to install the latest Git on Ubuntu. This guide covers two methods: the official PPA (quickest) and building from source.

The examples in this guide are run on WSL2 Ubuntu in Windows, but they work the same on any Ubuntu system.

Prerequisites

  • Ubuntu 22.04 or later (including WSL2)
  • A user with sudo privileges

Check Your Current Git Version

Before upgrading, check what version you currently have:

git --version

If the output shows anything older than 2.53.0 (the latest stable release as of February 2026), follow one of the methods below to upgrade.

Method 1: Install via the Official PPA (Recommended)

The git-core PPA is maintained by the Ubuntu Git Maintainers team and tracks the latest stable Git releases. This is the easiest and safest way to stay up to date.

1. Add the Git PPA

sudo add-apt-repository ppa:git-core/ppa -y

This registers the PPA so apt can pull the latest Git packages from it.

2. Update the Package Index and Install Git

sudo apt update && sudo apt install git -y
  • sudo apt update — refreshes the package index to include the new PPA
  • sudo apt install git -y — installs (or upgrades) Git to the latest version available in the PPA

3. Verify the Installation

git --version

You should see git version 2.53.0 or newer.

Method 2: Build from Source

If you need a specific version or want the absolute latest release before the PPA picks it up, you can compile Git from source.

1. Install Build Dependencies

sudo apt update && sudo apt install -y \
  build-essential libssl-dev libcurl4-gnutls-dev \
  libexpat1-dev gettext unzip zlib1g-dev

These are the libraries Git needs to compile with HTTPS, compression, and internationalization support.

2. Download the Source Code

Go to the Git releases on GitHub and find the version tag you want. Then download and extract it:

GIT_VERSION="2.53.0"
wget https://github.com/git/git/archive/refs/tags/v${GIT_VERSION}.tar.gz
tar -xzf v${GIT_VERSION}.tar.gz
cd git-${GIT_VERSION}

Replace 2.53.0 with whatever version you need.

3. Compile and Install

make prefix=/usr/local all
sudo make prefix=/usr/local install
  • prefix=/usr/local — installs Git to /usr/local/bin so it doesn’t conflict with the system package
  • make all — compiles Git and its documentation
  • sudo make install — copies the compiled binaries into place

4. Verify the Installation

git --version

If this still shows the old version, /usr/local/bin may not be first in your PATH. Check with:

which git

It should return /usr/local/bin/git. If not, add export PATH="/usr/local/bin:$PATH" to your ~/.bashrc and reload it with source ~/.bashrc.

Configure Git After Upgrading

If this is a fresh install, set your name and email so commits are properly attributed:

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

For push authentication without password prompts, see How to Configure Git Pushes Without Authentication Prompts.

Conclusion

You now have the latest Git running on Ubuntu. The PPA method is best for most users since it handles future updates automatically through apt upgrade. Building from source gives you more control when you need a specific version.

Now that Git is up to date, you might want to clean up stale branch references — see How to Remove Deleted Branches from Git Tab Completion. Or if you work with feature branches, check out How to Combine All Commits into One with GitLens Interactive Rebase in VSCode.