I read about a security flaw in Git, which was fixed in version 2.2.1. I currently have Git 2.1.0 on my system (Ubuntu 14.10), and tried to reinstall it with apt. However, apt told me that I currently have the latest version.

The Git website does not have prebuilt versions for Linux. They say that you can install it with package managers. Without building from source, how would I install the latest version of Git?


4 Answers 4


Use the PPA from the maintainers of git on Ubuntu:

sudo apt-add-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git

If you don't know what PPAs are, first read What are PPAs and how do I use them?

If you receive an error about add-apt-repository command not found you need to install software-properties-common, and then redo the above steps.

sudo apt-get install software-properties-common
  • 2.9.0 is the version I have just installed with this PPA, in case anyone is wondering...
    – Aaron Hall
    Jul 12, 2016 at 0:01
  • 1
    cool, now I can do git pull --rebase --autostash on 2.9 :) Jul 22, 2016 at 18:39
  • I used "apt-add-repository", it does not work. I used "add-apt-repository". I suspect a typo? Aug 7, 2016 at 15:21
  • 1
    For more clarification for later viewers, muru is correct that both commands should work. The first time when I used "apt-add-repository", it complains "Cannot add PPA: 'ppa:git-core/ppa'." Actually since the terminal didn't complain about the command not found, I should have not suspected the validity of the command. muru's response reminded me to test that command again. And the 2nd time I tried "apt-add-repository", it works! Both commands work! So I guess the failure of the first time I used that command might be due to something related to Internet. Aug 7, 2016 at 15:41
  • 1
    @JeffPuckettII It appears to be now at least. Git 2.10.1 (Oct 3) is available now.
    – MEMark
    Oct 23, 2016 at 18:59

This what i did to upgrade git to 2.xxx on Ubuntu 12.04:

sudo apt-get install python-software-properties
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:git-core/ppa -y
sudo apt-get update
sudo apt-get install git -y
git --version
  • 1
    The sudo apt-get upgrade could affect a LOT more than just git depending on the contents of the PPA, I'd recommend skipping that unless you know you want any packages that are newer in the PPA than just the dependencies that will be pulled in by the install git.
    – dragon788
    Jul 17, 2017 at 17:37
  • I edited the global apt upgrade out of the answer. Oct 26, 2017 at 19:52

The most common situation is when you want to install the latest version of git, but your Operating System's repositories are not updated. For example, in my case I have a laptop running Ubuntu 20.04, and when I executed the command sudo apt install git the installed version was 2.25.1; instead of 2.32.0 which is the current version at git-scm.com.

How can I get the latest version?

Well, we can install it by following one of these methods: Using APT Reprositories, Building and Installing or Using binary files.

A. Building and Installing (recommended for developers)

A-1. Uninstall the default version provided by Ubuntu's package manager and configuration by using:

sudo apt remove --purge --auto-remove -y git


sudo apt purge --auto-remove -y git

A-2. Go to the official CMake webpage, then download and extract the latest version. Update the version and build variables in the following command to get the desired version:

mkdir ~/temp
cd ~/temp
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-$version.$build.tar.gz
tar -xzvf git-$version.$build.tar.gz
cd git-$version.$build/

A-3. Install the extracted source by running:

make -j$(nproc) prefix=/usr/local all
sudo make prefix=/usr/local install

A-4. Test your new git version.

git --version

Results of git --version:

git version 2.25.X

B. Using PPA Repositories (recommended for normal users)

There is a PPA available from Ubuntu Git Maintainers team that we can use to easily install the latest stable Git version. So we can install it easily following these steps:

B-1. Uninstall the default version provided by Ubuntu's package manager as in A-1.

B-2. Add PPA repository to your sources list.

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

B-3. Finally we can update and install the git package.

sudo apt update
sudo apt install git

B-4. Test your new git version as in A-4.


In 2.32.X the X represents the last part of the version that we defined as build. The build may change if git is updated. According to the official web page the Latest Release is 2.32.0. If you want the Previous Release 2.31.1 just replace the version and build parameters like this:

mkdir ~/temp
cd ~/temp
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-git-$version.$build.tar.gz
tar -xzvf git-$version.$build.tar.gz
cd git-$version.$build/

Install specific version instead

If you want to install a specific version of the PPA, not necessarily the latest (I would recommend that for future reproducibility) you can use something like:

sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git=1:2.36.0-0ppa1~ubuntu20.04.1

This would install git 2.36 on Ubuntu 20.04.

The humongous version string 1:2.36.0-0ppa1~ubuntu20.04.1 was copy pasted directly from the PPA page: https://launchpad.net/~git-core/+archive/ubuntu/ppa

Some more info on version strings at: Why do some packages have extra numbers before a colon on the front of their version string?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .