I've just set up a new machine with Ubuntu Oneiric 11.10 and then run

apt-get update
apt-get upgrade
apt-get install git

Now if I run git --version it tells me I have git version but on my local machine I have the much newer git version

I know I can install from source to get the newest version, but I thought that it was a good idea to use the package manager as much as possible to keep everything standardized.

So is it possible to use apt-get to get a newer version of git, and what is the right way to do it?


You have several options:

  1. Either wait until the version you need is present in the repository you use.
  2. Compile your own version and create a deb.
  3. Find a repository that provides the version you need for your version of your distribution(e.g. Git PPA).
  4. If you don't need any particular feature from the newer version, stay with the old one.

If a newer version is available in the repositories you use, then apt-get update && apt-get upgrade (as root) updates to the latest available version.

For those who don't know what a PPA is, link

| improve this answer | |
  • 1
    +1 for the PPA. Otherwise compile from source and use checkinstall to cleanly install a .deb – Axel Knauf Mar 7 '12 at 15:54
  • 3
    The OP specifically asked for using the package manager, so only #3 applies. – Dan Dascalescu Aug 30 '16 at 5:02

Here are the commands you need to run, if you just want to get it done:

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

As of Dec 2018, I got git 2.20.1 that way, while the version in the Ubuntu Xenial repositories was 2.7.4.

If your system doesn't have add-apt-repository, you can install it via:

sudo apt-get install python-software-properties software-properties-common
| improve this answer | |
  • 12
    Useful for git on the Windows' Linux subsystem too – dumbledad Aug 17 '17 at 13:45
  • 2
    I tried sudo apt-get upgrade after sudo apt-get update and it didn't upgrade git, but sudo apt-get install git did. Why is that ?! – Muhammad Gelbana Sep 13 '17 at 9:16
  • 2
    It works on ubuntu 16.04 LTS – Roel Mar 6 '18 at 6:06
  • @MuhammadGelbana it works now. Tested on 18.04 LTS. – adadion Dec 10 '18 at 10:07
  • After adding the apt repo run sudo apt update then sudo apt upgrade and it should install the most recent version of git. At least it did in my case from v2.17.1 to v2.20.1 – Rockin4Life33 Jan 18 '19 at 23:51

Doing a search for "git ppa" gives Git stable releases. See instructions for installing here. You can also install the package by downloading directly from the web page, and installing with dpkg -i.

| improve this answer | |

To update git on Ubuntu 12.04 just follow this line of commands:

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 upgrade
sudo apt-get install git -y
git --version
| improve this answer | |

You can do this by homebrew in the easiest way:

install homebrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

upgrade git:

brew upgrade git
| improve this answer | |
  • 1
    The question has the tag [ubuntu] so a macOS solution does not help the OP, especially since they explicitly ask to do it using apt-get – Ciprian Tomoiagă Apr 28 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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