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.
We will see in this tutorial how to install Git on the Ubuntu 20.04 system using the command line.
Installing Git on Ubuntu 20.04
The Git can install on Ubuntu 20.04 system by using the two different methods:
- Install Git using the Apt package manager
- Git Installation from Source
Method 1: Install Git 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:
That’s the straightforward method to install Git on the Ubuntu 20.04 system using the apt repository.
Method 2: 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:
Step 1: Install important Git Dependencies
Install the all-important dependencies that are required to build the Git on your Ubuntu 20.04 system. Install all Git dependencies by using the below-mentioned command:
$ sudo apt install dh-autoreconf libcurl4-gnutls-dev libexpat1-dev make gettext libz-dev libssl-dev libghc-zlib-dev
Step 2: Download Git package from source
Download the latest Git release from the source and then extract it by executing the following command:
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-*
Once the Git installation is completed, verify the installation by using the following command:
$ git –version
Step 3: Git configurations on Ubuntu 20.04
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"Code language: PHP (php)
$ git config --global user.email "firstname.lastname@example.org"Code language: PHP (php)
Verify changes in Git configuration.
$ git config –listCode language: PHP (php)
We installed Git on the Ubuntu 20.04 system in this article. After installing Git, you can use Git features on your system. Now, you can efficiently collaborate on your projects. Thanks!
Another interesting article may be: Easy Way to Install Kile LaTeX Editing Environment