Git is the most popular distributed version control and source code management system. In addition,Git was designed and developed by Linus Torvalds for Linux kernel development.
This guide explains how to install Git on Ubuntu 20.04 LTS using the APT package manager, or by compiling it from a source.
Step 1. Installing Git
Installing Git with Apt
-The Git package is included in Ubuntu’s default repositories and can be installed using the apt package manager. This is the most convenient and easiest way to install Git on Ubuntu.
– So, execute the below commands to install Git:
$ sudo apt update $ sudo apt install git
Installing Git From Source
To install the latest version of Git, you have to compile it from a source. So, follow the next steps:
1- Start by installing the dependencies necessary to build Git on your Ubuntu system
$ sudo apt update $ sudo apt install dh-autoreconf libcurl4-gnutls-dev libexpat1-dev make gettext libz-dev libssl-dev libghc-zlib-dev
2- Second, visit the Git project’s mirror on GitHub and copy the latest release link URL that ends in
.tar.gz.. the latest stable Git version is 2.26.2
3- Now, Let’s download and extract the Git source in the
$ wget -c https://github.com/git/git/archive/v2.26.2.tar.gz -O - | sudo tar -xz -C /usr/src
3- Finally, when the download is complete, change to the source directory and run the following commands to compile and install Git:
$ cd /usr/src/git-* $ sudo make prefix=/usr/local all $ sudo make prefix=/usr/local install
Step 2./ Verifying the installation
– To verify the installation type the following command which will print the Git version:
$ git --version git version 2.26.2
Step 4./ Configuring Git
– Once the installation is successfully finished. Use the following commands to provide global Name and Email address that will be embedded into your code commits:
$ git config --global user.name "Waderni Lotfi" $ git config --global user.email "[email protected]"
– To check if your configurations are added successfully, use the below command:
$ git config --list user.name=lotfi [email protected]
– The configuration settings are stored in the
[user] name = lotfi email = [email protected]
You have successfully installed the latest version of Git on your Ubuntu 20.04 LTS Server. However, to learn more about how to use Git you can visit the Git official Documentation website.
You might want to check the following guides: