How to install Git on Ubuntu 20.04

by Pete Wan

In a freshly installed Ubuntu system you may find that Git is not installed. You can check for the Git version on your machine by entering the following in a terminal:

$ git --version

If Git is installed the terminal response will look like:

git version 2.25.1

otherwise the response will be:

Command 'git' not found, but can be installed with:
sudo apt install git

Git installation and basic configuration

Step 1. Install Git

1. Open a terminal.

2. Update apt index:

$ sudo apt update

3. Install Git with apt:

$ sudo apt install git

4. Verify installation is successful by checking Git version:

$ git --version

The response should be similar to:

git version 2.25.1

Step 2. Configure Git

1. Globally configure your username and email:

$ git config --global "John Doe"
$ git config --global

2. Globally configure editor (e.g. nano) used by Git:

$ git config --global core.editor nano

3. If your machine is working behind a corporate proxy then globally configure the proxy:

$ git config --global http.proxy http://yourProxyUsername:yourProxyPassword@yourProxyDomain:port  

4. Finally, check your Git configuration:

$ git config --list --show-origin

Your git configurations are stored in a .gitconfig file located in your home directory i.e. ~/.gitconfig

Leave a Comment