How To Install Git on Ubuntu 16.04

Overview

In this tutorial we will learn how to install git on Ubuntu 16.04 (Xenial Xerus).

Git is a free and open source distributed version control system (VCS) designed to handle all project from small to large with speed and efficiency.

Originally created by Linus Torvalds in 2005 and maintained by Junio Hamano since July 2005. It’s used by many open source projects like the Linux kernel, KDE, Eclipse, PostgreSQL and Qt.

Git also being used by large companies including but not limited to Google, Facebook, Microsoft, Linkedin, Netflix and Twitter.

You can visit git website to learn more about git usage.

Let’s start installing git on Ubuntu 16.04.

Install Git on Ubuntu 16.04 from repository

Ubuntu 16.04 already shipped with git version 2.7.4. Let’s install git from repository.

Update repository metadata using command below


$ sudo apt-get update

Now let’s install git


$ sudo apt-get install git

Press Y to continue.

Check installed git version


$ git version
git version 2.7.4

Install Git from PPA repository

If we check on git website, at the time of this writing the latest stable version of git is 2.13.3.

We can install the latest stable git from git core PPA repository.

Add git-core PPA repository


$ sudo add-apt-repository ppa:git-core/ppa
 The most current stable version of Git for Ubuntu.

For release candidates, go to https://launchpad.net/~git-core/+archive/candidate .
 More info: https://launchpad.net/~git-core/+archive/ubuntu/ppa
Press [ENTER] to continue or ctrl-c to cancel adding it

Press ENTER


gpg: keyring `/tmp/tmpb_shleu6/secring.gpg' created
gpg: keyring `/tmp/tmpb_shleu6/pubring.gpg' created
gpg: requesting key E1DF1F24 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpb_shleu6/trustdb.gpg: trustdb created
gpg: key E1DF1F24: public key "Launchpad PPA for Ubuntu Git Maintainers" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK

Update apt-get metadata by running command below


$ sudo apt-get update

Install git


$ sudo apt-get install git

Now when we check git version


$ git version
git version 2.13.0

We already use the latest version of git installed.

Summary

In this tutorial we learned how to install git from Ubuntu repository on Ubuntu 16.04 and also latest version of git from git-core PPA repository.

Now you can start using git to version control your source code, configuration, or any work that you plan to use version on.