How To Install Git on Ubuntu 16.04

/ Category: Tutorials / Comments: None

how to install git on ubuntu 16.04
Spread the love

Git is a free and open source distributed version control system, originally developed in 2005 by Linus Torvalds, the great creator of the Linux operating system kernel. In this tutorial, we will show you how to install GIt on Ubuntu 16.04 and discuss how Git can help improve your development workflow.


  • You need to run a server with any Ubuntu 16.04 LTS release.
  • You should log in to SSH using the root user.

The first thing that should be done is to run general OS and package updates. On Ubuntu you can do that by executing the following command:

apt-get update

Then, after the general updates on the server have been run, you can start with the installation of Git.

Install Git

apt-get install git

If you are asked to confirm the download of the installation; Just press Y to confirm. It is simple as that.

Confirm Git the installation

Once you are done with the main installation, you need to check and make sure that the executable file is set up and accessible. You can do this by running Git with the version command.

#git --version
git version 2.17.0

How To Install Git from Source

Another way to install Git, which is more flexible, is to compile the software from source. This method takes more time and it won`t be maintained through the package manager, but you will get the chance to download the latest version and you will have the control over the options that can be included if you want to customize it.

Update and install the local package index

sudo apt-get update
sudo apt-get install build-essential libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip

When all the necessary dependencies are done and installed, you will be able to get the git version you want and you can do that by visiting the git project`s mirror on GitHub.

If you wish to get the latest stable version, all you have to do is to go and change the branch to the latest non-“rc” tag via the button along the left side of the project header:

Then, on the right side of the page, right-click the Download ZIP button and you need to copy the link address.

Now go back to the Ubuntu 16.04 server where you need to type wget and then to paste the copied address. Have in mind that the URL which you copied can differ from this example:

wget -O

The next step s to unzip the downloaded file and move it in the result directory by typing:

cd git

At this point, by typing the following commands, you can create the package and install it:

make prefix=/usr/local all
sudo make prefix=/usr/local install

Since you already installed git, you may want to upgrade it to its latest version, and that is quite simple – all you need to do is clone the repository (be sure that you have changed it to your home directory) and next build and install. Navigate to the branch in order to find the URL which you need to use for the clone operation or also you can tag the things you want on the project`s GitHub page and simply copy the clone URL on the right:

git clone URL

Once again, don`t forget to change to your home directory and use the already copied URL:

cd ~
git clone

By taking these steps you will create new directory within the existing one and there you will be able to rebuild the packages and of course to reinstall the latest version. This is how your older version will be overwritten with the new version:

cd git
make prefix=/usr/local all
sudo make prefix=/usr/local install

Configure root user

Configure Git’s settings (for the root user)

Now you should set up your user for git in order to prevent some commit errors later. We’ll set up the user gituser with the e-mail address [email protected]

git config --global "gituser"
git config --global "[email protected]"

Verify the Config changes

At this point the configuration changes should be verified and that can be done by viewing the .gitconfig file. This can be done in various ways and here you can see the methods.

You can use cat with the following command in order to view the config file:

cat ~/.gitconfig

You can also use the git config command in order to view the same details:

git config --list

And that’s it, now you have Git installed on your Ubuntu 16.04 server and you have also configured it on your root user. You can get rolling with your code changes from here, or you can repeat the steps for other system user accounts.

install git on ubuntu 16.04Of course, you don’t need to install Git on your Ubuntu 16.04 machine yourself if you have an high-speed Ubuntu VPS hosted with us – in which case, you can contact our team of Linux experts who can install and configure Git for you. They are available 24/7 and can help with any requests or questions that you may have.

PS. If you liked this post, feel free to share it by using the social media share buttons below, or simply leave a comment. Thanks.

Be the first to write a comment.

Your feedback