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?

up vote 162 down vote accepted

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 may need to add the python-software-properties package or software-properties-common depending on your Ubuntu version.

Ubuntu 14.04

sudo apt-get install software-properties-common

Ubuntu 13.10 or earlier

sudo apt-get install python-software-properties
  • 2.9.0 is the version I have just installed with this PPA, in case anyone is wondering... – Aaron Hall Jul 12 '16 at 0:01
  • cool, now I can do git pull --rebase --autostash on 2.9 :) – Oscar Mederos Jul 22 '16 at 18:39
  • I used "apt-add-repository", it does not work. I used "add-apt-repository". I suspect a typo? – user1914692 Aug 7 '16 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. – user1914692 Aug 7 '16 at 15:41
  • 1
    @JeffPuckettII It appears to be now at least. Git 2.10.1 (Oct 3) is available now. – MEMark Oct 23 '16 at 18:59

This what i did to upgrade git 1.7.9.5 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
  • 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 '17 at 17:37
  • I edited the global apt upgrade out of the answer. – Duncan Lock Oct 26 '17 at 19:52

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.