How to install or update Git on Ubuntu box

Here's a short memo on how to tell apt-get about the new Git version.

Install or update via apt-get

Check if Git is installed and what version it’s on:

$ git --version
git version

Ideally you would just go:

$ sudo apt-get install git

The Git version in apt-get is stuck to, that might be okay for you. If you want the latest 2.3.4 (at the time of writing this), you need to add the latest Git to apt-get with the following command:

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

It’s maintained by these people.

Now apt-get knows about the new Git, then install it:

# First update the apt-get package database
$ sudo apt-get update
# Then install git
$ sudo apt-get install git
# Check version and do a little dance
$ git --version
git version 2.3.4


If you get an error

sudo: add-apt-repository: command not found

Then you simply need to install it:

$ sudo apt-get install software-properties-common python-software-properties

Club-Mate, the beverage →