How can I update to a newer version of Git using apt-get?

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

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


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.