1. Add PPA repository
Official Ubuntu software repository usually do not have the latest version of software packages (in this case git). Personal Package Archives (PPA) are maintained by the developer of a specific software, therefore usually have the latest version. To get the latest version of git, add PPA for git to software sources as follows:

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

2. Update and Install
Then git can be installed or updated.

sudo apt-get update
sudo apt-get install git