Hello friends, Ashish on the behalf of Tastethelinux, will present “how to install GIT on Ubuntu 20.04 Linux.”
What is GIT?
GIT is the Version control system used to manage the source code of an application. GIT is where many developers can work on the same source code with the Sync.
The main advantages of the GIT are that we can merge the source codes, revert the code, also we can manage the different version controls.
Install GIT on Ubuntu 20.04 Linux
We will use two ways to Install Git in Ubuntu 20.04. Both the ways are a little bit different from one another.
- Install GIT on Ubuntu 20.04 via the command line.
- Install GIT on Ubuntu 20.04 via Source Code.
How to Install GIT on Ubuntu 20.04 Linux via Command Line.
Let’s update the repositories on Ubuntu first, and then we will install GIT.
$ sudo apt update -y
After updating the repositories, we will use the apt command for the installation.
$ sudo apt install git -y
So the above command will download the GIT with its dependencies packages and install all the required packages for GIT.
Once installed, we will check the version for the GIT, by using the git command on the terminal.
$ git --version
The Output “git version 2.25.1” is the git version installed via “apt command”, let’s install via Source Code
How to Install GIT on Ubuntu 20.04 Linux via Source Code.
So let’s install git via source code then we have to download the git source from GitHub, but before that, we have to install some of the dependencies.
$ sudo apt install make libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip -y
So, we have downloaded some library packages, unzip, now download the git via the wget command
So, first I visit to https://github.com/git/git/releases and right click on the tar.gz and select the “Copy link address”.
Then copied link will be used with the wget command to download the GIT source file.
$ wget https://github.com/git/git/archive/refs/tags/v2.32.0.tar.gz
Once the source code gets download then we will extract the source code via the tar command.
$ tar -zxvf v2.32.0.tar.gz
So after that extract, the package. Now go into the folder, and compile the package.
$ cd git-*
$ sudo make prefix=/usr/local all
Once we have done the compilation successfully, we will install all the packages.
$ sudo make prefix=/usr/local install
After that just create a soft link to use the GIT command, if not created it will give the error “git command not found”
$ sudo ln -s /usr/local/bin/git /usr/bin/git
After creating the soft link will check the version for the GIT.
$ git --version OUTPUT: git version 2.32.0
Configure GIT on the Local System.
To configure GIT on the local system, we will use the config option with the git command.
$ git config --global user.name "tastethelinux"
So we have configured the username for the git, now configure the user email ID with the parameter “user.email”.
$ git config --global user.email "[email protected]"
By using the –list option, you can check the configured user name and email ID.
$ git config --list OUTPUT: user.name=tastethelinux [email protected]
You can configure and then take the clone of your repository and use the GIT. Comment to me in the comment section if you face any difficulties.