×


Install Git on Ubuntu 20.04 - Step by step guide ?

Git is the most commonly used and popular distributed version control platform that is used by many commercial and open-source projects. Using Git, you can collaborate with your project developers. Moreover, you can keep track of code changes, create branches, revert to previous stages, and more.

Here at Ibmi Media, we shall look into how to install Git on the Ubuntu 20.04 system using the command line.


Different ways to install Git on Ubuntu 20.04

  • Git installation using the Apt package manager.
  • Git installation from Source.


a. Git installation using the Apt package manager

The Git package is available for installation in the default Ubuntu 20.04 packages repository. Therefore, the Git installation using the Ubuntu apt repository is the easiest and most convenient way. If you want to install the Git latest version on your system then, it is recommended that install Git from Source on your Ubuntu system.

Let’s start installing Git using the apt repository. First, update the system packages index by using the below-mentioned command:

$ sudo apt update

Now, install Git by executing the below-mentioned command with root privileges:

$ sudo apt install git

Verify the installation of Git by using the below-mentioned command:

$ git –version

The installed version will show on the terminal window:


b. Git installation from Source.

It is recommended to install Git from the source because when you install Git using this method, you can compile the latest Git release on your Ubuntu system and can customize the different build options.

Follow the following steps to install Git from the source:

1. Install important Git Dependencies

Install the all-important dependencies that are required to build the Git on your Ubuntu 20.04 system with the below command:

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

2. Download Git package from source

Download the latest Git release from the source and then extract it by executing the following command:

$ wget -c https://github.com/git/git/archive/v2.26.2.tar.gz -O - | sudo tar -xz -C /usr/src

Once the Git package is downloaded, change the source directory using the ‘cd’ command and then start installing Git by using the below-mentioned commands:

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

Once the Git installation is completed, verify the installation by using the following command:

$ git –version

2. Git configurations on the system

After completing the Git installation on Ubuntu 20.04 system, you will enter your user name and email in the Git configuration. Git associates user identity at every commit. All Git configurations are stored in the '~/.gitconfig' file. So, to use the commit name as global, mention your user name and email address:

$ git config --global user.name "Use-Name"
$ git config --global user.email "email@domain.com"

Verify changes in Git configuration:

$ git config –list


How To Uninstall git from Debian 11 ?

To uninstall only the git package we can use the following command:

$ sudo apt-get remove git

We can use the following command to remove git configurations, data and all of its dependencies, we can use the following command:

$ sudo apt-get -y autoremove --purge git


[Need help in fixing Ubuntu Linux system issues ? We can help you. ]


Conclusion

This article covers how to easily install Git on the Ubuntu 20.04 system. In fact, GIT is for developers that need a pretty straightforward version control system. Most software is collaborative efforts and sometimes can have hundreds of people with commits working on software development projects. It’s essential to track these commits customarily done in branches in most projects before merging into the master for release. It is easy to review and track down any incorrect commits and revert, leading to a much easier development if anything goes wrong.


How to Check Git Version ?

You can check to see what version of git you are currently running, if any, with the following command:

$ git --version