How To Install Git on Ubuntu 18.04 / 20.04

April 10, 2019


Git is a version control system used in modern software development. It allows multiple developers to work on the same project while tracking changes, revisions, and contributors.

This step-by-step guide walks you through installing and configuring Git on Ubuntu 18.04 or Ubuntu 20.04.

tutorial on installing and using git for all current ubuntu versions


  • Access to a user account with sudo or root privileges
  • A server with any Ubuntu release up and running.
  • Access to a command line/terminal window (Ctrl-Alt-T)
  • The apt-get tool, pre-loaded in Ubuntu and other Debian-based distros

Install Git with Apt on Ubuntu

Using the apt package management tool is the easiest way to install Git. However, the version in the default repositories may not be the latest release from the developer. If you want to install the latest release, skip down to install from source.

1. To update the packages, launch a terminal window, and enter:

sudo apt-get update

This helps to ensure you’re working with the latest software versions.

2. To install from the default repositories, enter the following:

sudo apt-get install git

Allow the process to complete.

3. Verify the installation and version by entering:

git --version

The output should appear as seen below:

verifying that git was installed successfully on ubuntu

Install Git From Source Code

To use the latest version of Git on Ubuntu, download and install from the original source code.

1. Start by installing the following packages:

sudo apt install make libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip

Allow the process to complete.

2. Open a browser window and navigate to the following address:

3. You can select the version of Git you download by changing the branch to a specific version. Select the Master Branch.

Also, at the top, you see a link labeled releases to browse the different release versions. It is recommended that you avoid versions labeled with “rc.” This stands for release candidate, and may not be completely stable.

screenshot of the master download of git with releases

4. Click the green Clone or download button on the right-hand side. Copy the URL by clicking on the file icon.

clone button highlighted in git download

5. Switch back to your command prompt and enter the following:

cd /tmp

6. You are now working in the temp directory. Type in the following command:

sudo wget -O

This downloads the Git file, and renames it

Note: If you found a package under the releases page, you can substitute the link to that version. For example:

sudo wget -O

7. Next, extract the zip files by entering the command:


8. Allow the process to finish. Then, move to the new directory:

cd git-*
moving to the big-master directory

9. Then, compile the package with the following command:

make prefix=/usr/local/

10. And once the process is finished, install the software with:

sudo make prefix=/usr/local install

11. Verify Git installation by entering:

git --version

The output should appear as:

Git version 2.18.0

Configuring Git

Git contains a basic configuration file that holds your information. Setting your username and email address is essential.

1. In a terminal window, enter the following and replace your_name with your name, and [email protected] with your email address.:

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

2. Verify configuration changes with the command:

git config --list

The system should display the name and email address you just entered.

confirmation of email during git setup on ubuntu

Note: If you do not make these edits, you will receive a warning when you commit to Git which makes you go back and revise your commits.

Basic Git Commands

This is a list of useful Git commands to help you get started:

  • Find changed files in the working directory: git status
  • Change to tracked files: git diff
  • Add all changes to your next commit: git add
  • Add selected changes into your next commit: git add -p
  • Change the last commit: git commit -amend
  • Commit all local changes in tracked files: git commit -a
  • Commit previously staged changes: git commit
  • Rename a Local branch git branch -m new-name
  • List all currently configured remotes: git remote -v
  • View information about a remote: git remote show
  • Add a new remote repository: git remote add
  • Delete a remote repository git remote remove [remote name]
  • Download all changes from a remote repository: git fetch
  • Download all changes from and merge into HEAD: git pull branch
  • Create a new branch with the command: git branch first-branch

To see more git commands use: git --help


Now you know how to install Git on your Ubuntu system. You also learned configuration and basic Git commands, which will help you manage your projects more effectively.

For CentOS, Windows, or macOS systems, see our guide on installing Git on CentOS 7, installing git on Windows, and installing Git on MacOS. Also, don’t forget to download our Git Commands Cheat Sheet for free to have the most commonly used commands always at your hand.

Was this article helpful?
Sofija Simic
Sofija Simic is an experienced Technical Writer. Alongside her educational background in teaching and writing, she has had a lifelong passion for information technology. She is committed to unscrambling confusing IT concepts and streamlining intricate software installations.
Next you should read
How to Install and Use Git on Windows
January 8, 2020

Git tracks source code changes during the software development process. It can help coordinate work among...
Read more
How To Rename a Local and Remote Git Branch
January 6, 2020

Git is a version control system that helps you control the stages of software development. It uses named...
Read more
How to Create a New Branch in Git
February 24, 2022

This article outlines the basic commands needed to create a Git branch. A Git branch allows you to work on...
Read more
How to Install Git on CentOS 7 With Yum or Latest Repository
March 15, 2019

In this tutorial, learn how to install Git on CentOS 7. Git is a distributed version control system to track...
Read more
  • © 2022 Copyright phoenixNAP | Global IT Services. All Rights Reserved.