Read in 3 minutes
How To Install Git on Ubuntu 18.04
This tutorial will guide you through the steps required to install Git on Ubuntu 18.04.
Git is a de-facto standard for distributed version control system and is used by majority of developers nowadays. It allows you to keep track of your code changes, revert to previous stages, create branches and to collaborate with your fellow developers.
Git is originally developed by Linus Torvalds, the creator of the Linux kernel.
This tutorial was tested on Ubuntu 18.04 but it should also work with any previous Ubuntu version.
Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges.
Installing Git with Apt
The easiest and the recommended way to install Git is to install it using the apt package management tool from the Ubuntu’s default repositories. If you want to install the latest stable version of Git from source move on to the Installing Git from Source section of this tutorial.
Follow this steps to install Git on your Ubuntu system:
Updating package index
As always before installing new packages first update the apt package index:
sudo apt update
Installing Git on Ubuntu
From your terminal run the following command to install Git:
sudo apt install git
To verify the installation type the following command which will print the Git version:
git version 2.17.1
At the time of writing this article, the current version of Gin available in the Ubuntu 18.04 repositories is
2.17.1, which is only one version behind the latest Git version (
Installing Git from Source
Another option is to compile Git from source which will allow you to install the latest Git version and to customize the build options, but you will not able be to maintain your Git installation through the
apt package manager.
First you need to install the dependencies necessary to build Git on your Ubuntu system:
sudo apt update sudo apt install make libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip
Once the installation is completed open your browser, visit the Git project’s mirror on GitHub and copy the latest release link URL that ends in
At the time of writing this article, the latest stable Git version is
We are going to download Git source in the
/usr/src directory which is the common location to place source files, change to the directory with:
Download the tar.gz file as
git.tar.gz using the following wget command:
sudo wget https://github.com/git/git/archive/v2.18.0.tar.gz -O git.tar.gz
Next, extract the tarball and change to the git source directory by typing:
sudo tar -xf git.tar.gz cd git-*
Run the following two commands to compile and install Git on your Ubuntu system:
sudo make prefix=/usr/local all sudo make prefix=/usr/local install
To verify the installation type the following command which will print the installed Git version:
git version 2.18.0
If you want to upgrade to a newer version, you will need repeat the installation process.
Now that you have git installed it is good idea to set up your personal information that will be used when you commit your code:
git config --global user.name "Your Name" git config --global user.email "[email protected]"
To verify the configuration changes you can use the following command:
git config --list
user.name=Your Name [email protected]
The configuration settings are stored in the
[user] name = Your Name email = [email protected]
If you want to make further changes to your Git configuration you can either use the
git config command or edit the
~/.gitconfig file by hand.
You have learned how to install Git on your Ubuntu system. You should now check the Pro Git book and learn more about how to use Git.
If you hit a problem or have a feedback, leave a comment below.