Open In App

How To Install Git on Ubuntu 20.04

Last Updated : 20 Mar, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Git, a popular version control system, is widely used for managing code in software development projects. It tracks changes in code, allowing collaboration and easy reversion to previous versions if needed. This article will outline two methods for installing Git on your Ubuntu system.

Method 1 : Using APT package manager

Step 1 : Update the package list

To make sure we are getting the latest version of git, update the package list using apt update command.

 sudo apt update -y
updating-repos
updating system

Step 2 : Install Git

Once repositories are up to date, we will install git using apt install command.

sudo apt install git -y
installing-git-using-apt
installing git using apt package manager

Step 3 : Verify installation

Once, installation is done, verify installation using git --version command.

git --version
image_2024-03-19_143940089
verifying installation

Method 2 : Compiling from sources

Step 1 : Installing dependencies

In order to install git from Tarball package, we will need to download required dependencies using apt install command as follows

sudo apt-get install dh-autoreconf libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev build-essential
installing-git-dependencies
installing git dependencies

Step 2 : download archive

In this step, we will download official Tarball package from official git repository. Go to following link in your browser and download latest .tar.gz package as shown below

Link : https://github.com/git/git/tags


downloading-tarball-package
downloading tarball latest package

Step 3 : Extract the archive

Once downloading is completed, we will extract the package using tar -zxf command.

First navigate to Downloads folder using cd command

cd Downloads

Now extract tarball package using tar -zxf command

tar -zxf git-*

Step 4 : Navigate to the extracted directory

Once extracted, navigate to extracted directory using cd command.

cd 
cd Downloads/git-2.44.0/
navigating-to-extracted-directory
navigating to extracted directory

Step 5: Configure and build

Once we are in extracted git directory, use following commands to make configurations and installation.

make configure
making-config
configuring installation
./configure --prefix=/user
configure-for-user
configure for user
sudo make install install-doc install-html install-info
installing-git
installing git

Step 6 : Verify installation

Once, installation is done, verify installation using git -v command.

 git -v

verifying-git-installation

Conclusion

In this article, we've explored two methods for installing Git on Ubuntu 22.04. For most users, using the Ubuntu repositories (via the apt package manager) is the recommended approach. This method offers a straightforward installation, ensures compatibility with your system, and provides regular security updates. However, if you require a specific Git version or prefer more customization, compiling from source is an alternative option.


Next Article
Article Tags :

Similar Reads