How to Install Git on Ubuntu 20.04

GitHub is a provider of Internet hosting and cloud-based service for software development, source code management (SCM) and distributed version control using Git. It helps developers store and manage their code, as well as track and control changes to their code. GitHub commonly used to host open-source projects.

Additionally, anyone can sign up and host a public code repository for free, which makes GitHub especially popular with open-source projects. It provides access control and several collaboration features such as bug tracking, task management, feature requests, continuous integration and wikis for every project.

Git is originally developed by Linus Torvalds , the creator of the Linux kernel. It’s interface is user-friendly enough so even novice coders can take advantage of Git. Without GitHub, using Git generally requires a bit more technical savvy and use of the command line.

Key Features of Git

  • Collaborative Coding
  • Visual Studio Code backed by high performance VMs that start in seconds.
  • Get updates on the GitHub activity you’ve subscribed to.
  • Review new code, see visual code changes, and confidently merge code changes with automated status checks.
  • Code review assignments
  • Automatically request reviews–or require approval—by selected contributors when changes are made to sections of code that they own.
  • Request a team on GitHub to review your pull request.
  • Request review from multiple contributors.
  • Multi-line comments
  • Public repositories

This article explains two methods of installing Git on Ubuntu 20.04.

Choose the installation method that is most appropriate for your environment.

Method 1: Installing Git using APT

In this method we will install the Git via apt and the installation is very straightforward.

Step #1

Git is available in the universe repository of all Ubuntu releases.

Note: Though it is usually enabled by default, It won’t harm to enable universe repository first.

$ sudo add-apt-repository universe

Step #2

Then type the following command to update the package index.

$ sudo apt update && sudo apt upgrade

Step #3

Finally execute the following command to install Git on Ubuntu.

$ sudo apt install git

You can be sure that your install was successful by checking the version.

$ git --version

At this step, you have successfully installed Git application on Ubuntu 20.04 system.

Method 2: Installing Git from Source

If you’re looking for a more flexible method of installing Git, you may want to compile the software from source.

This takes longer and will not be maintained through your ubuntu package manager, but it will allow you to download the latest release and will give you greater control over the options you include if you wish to make customizations.

Step #1

Start by installing the dependencies necessary to build Git on your Ubuntu system.

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

Step #2

Create a temporary directory and move into it. This is where we will download our Git tarball package.

$ mkdir tmp && cd /tmp

From the official Git project website, we can navigate to the tarball list and download the version you would like.

At the time of writing this article, the latest stable Git version is “2.26.2”. We’ll use curl and output the file we download to git.tar.gz.

$ curl -o git.tar.gz

Step #3

Now type the following command to extract the compressed tarball file.

$ tar -zxf git.tar.gz

Change to the source directory and run the following commands to compile and install Git Package.

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

Once completed, verify the installation by running the following command.

$ git --version

With Git successfully installed, you can now complete your setup.

Configuring Git

After you are pleased with your Git version, you should configure Git so that the generated commit messages you make will contain your correct information and support you as you build your software project. You need to configure your git username and email address. Git associate your identity with every commit you make.

Configuration can be achieved by using the git config command. To set your global commit name and email address run the following commands.

$ git config --global "Your Name"
$ git config --global "[email protected]"

Type the following command to display all of the configuration items that have been set.

$ git config --list

Output: Name
[email protected]

The configuration settings are stored in the ~/.gitconfig file. You can optionally edit by hand with a text editor of your choice like this.

$ vi ~/.gitconfig

How to Uninstall Git from Ubuntu 20.04

For some reason, If you want to uninstall Git, type the following command.

$ sudo apt-get remove git


I hope that now you have a good understanding of How to Install Git on Ubuntu 20.04 LTS Focal Fossa.

If anyone does have any questions about what we covered in this guide then feel free to ask in the comment section below and I will do my best to answer those.


If you like our content, please consider buying us a coffee.

Buy Me A Coffee

We are thankful for your never ending support.

Leave a Comment

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