How to Install Git on Ubuntu 20.04 Easily

0

Git is the most popular open-source distributed version control system. It allows you to keep track of your code changes, revert to previous stages, create branches, and collaborate with your co-developers. Git is compatible with all modern operating systems. In this tutorial, you will learn how to install git on Ubuntu 20.04.

Before installation, you can check the system, whether git is installed or not by the following command.

$ git --version

How to Install Git on Ubuntu 20.04

Git can be installed in two ways

  • Install Git with Default Packages.
  • Install Git from the Sources.

Install Git with Default Packages

The easiest and recommended way to install git on Ubuntu is from the packages manager using apt command. Before installation of any application on Ubuntu, it is always recommended to update the default packages. To update the default packages, run the following command.

$ sudo apt update

Once the update is completed, you can install git by following command.

$ sudo apt install git

Now, verify the installation by checking the version of the git.

$ git --version

Output:

[email protected]:~$ git --version
git version 2.32.0

Install Git from the Sources

You can alternatively install the latest version from the sources. To install git from the sources, you have to update some library packages first.

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

Once the package installation is completed, open the git projects repository on the browser.

https://github.com/git/git

How to Install Git on Ubuntu

Copy the tar.gz file download link by right clicking on tar.gz as highlighted above. Use wget command to download the file.

$ wget https://github.com/git/git/archive/refs/tags/v2.32.0.tar.gz -O git.tar.gz

Above command will download the git file and rename it to git.tar.gz. Now, to extract the .tar.gz file run below command.

$ tar -zxf git.tar.gz

Above command will download the git file and rename it to git.tar.gz. Now, to extract the .tar.gz file run below command.

$ tar -zxf git.tar.gz

Next, move to the git directory

$ cd git-*

Install the packages by running the following commands.

$ make prefix=/usr/local all
$ sudo make prefix=/usr/local install

After installation checks the git version by the following command.

$ git --version

Hurray, you have successfully installed the latest version of git.

Git Basic Configuration

Before using git, you need to configure with basic details, so that your generated commit message will have your details. To configure the git, run the git config command. You need to add your NAME and EMAIL to the git configuration by the following command.

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

You can check your configuration by following command.

$ git config --list

You can edit the information also by editing the file.

$ sudo vi ~/.gitconfig

Conclusion

In this tutorial, you have learned how to install git on Ubuntu 20.04. If you have any doubts feel free to contact me, I will definitely try to help you. Also, you can join our elite facebook group to get direct help from me. If you like this tutorial, please share this article on your social media handle.

LEAVE A REPLY

Please enter your comment!
Please enter your name here