# How to install the latest version of Git on an Ubuntu box

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

## Install or update via apt-get

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

```shell
$ git --version
git version 1.7.9.5
```

Ideally you would just go:

```shell
$ sudo apt-get install git
```

The Git version in apt-get is stuck to `1.7.9.5`, that might be okay in most
cases, but 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:

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

The repo is maintained by
[these people](https://launchpad.net/~git-core/+archive/ubuntu/ppa).

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

```shell
# 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
```

## Troubleshooting

If you get an error like:

```
sudo: add-apt-repository: command not found
```

Then you need to install the `software-properties-common` package:

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