How to Install Git on Ubuntu

This brief tutorial shows students and new users how to install Git on Ubuntu 20.04 | 18.04.

Git is probably the most popular opensource, distributed version control system in use today. Git allows developers to keep tracks of projects, code changes, create and revert changes, as well as collaborate with other developers.

Originally created by Linux Torvalds, the creator of the Linux operating systems, Git is now owned by Microsoft.

If you’re a student or new user looking for an easy tutorial on installing Git on Ubuntu, the steps below should come in handy.

Students or new users looking for a Linux system to begin with, the easiest place to start is Ubuntu Linux OS. It’s a great Linux operating system for beginners.

Ubuntu is an open source Linux operating systems that runs on desktops, laptops, server and other devices.

To get started with installing Git on Ubuntu, follow the steps below:

Install Git from Repository

Git packages come ready to install from Ubuntu default repositories. You can simply run apt get command to install it in Ubuntu. However, the versions that are available in Ubuntu repositories may not necessarily be the latest.

The installation is pretty straightforward. Simply run the commands below to install Git on Ubuntu.

sudo apt update
sudo apt install git

That should download and install Git packages.

To verify that Git is installed and functioning, run the commands below

git --version

The command above will output the line below:

git version 2.25.1

You have successfully installed Git on Ubuntu.

Install Git from Source

Again, as we mentioned above, the version that comes with Ubuntu might not necessarily be the latest. To install the latest, you will want to install build and install it from source.

To do that, use the steps below.

First, install required and recommended packages to build Git. Run the commands below to do that.

sudo apt update
sudo apt install dh-autoreconf libcurl4-gnutls-dev libexpat1-dev make gettext libz-dev libssl-dev libghc-zlib-dev

Next, go to Git project page to check the latest releases. Get the release version and replace the one below if it’s newer.

wget -c -O - | sudo tar -xz -C /usr/src

Once the download is complete, change into source directory and run the commands below to compile and build Git.

cd /usr/src/git-*
sudo make prefix=/usr/local all
sudo make prefix=/usr/local install

Depending on the speed of your machine, compiling should take couple of minutes. Once done, you can verify Git version by running the command below again.

git --version
git version 2.32.0

That should do it!


This post showed you how to install Git on Ubuntu 20.04 | 18.04. If you find any error above, please use the comment form below to report.

You may also like the post below:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.