How To Install Git on Ubuntu 20.04
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.
Table of Content
- Method 1 : Using APT package manager
- Method 2 : Compiling from sources
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
Step 2 : Install Git
Once repositories are up to date, we will install git using apt install command.
sudo apt install git -y
Step 3 : Verify installation
Once, installation is done, verify installation using git –version command.
git --version
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
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
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/
Step 5: Configure and build
Once we are in extracted git directory, use following commands to make configurations and installation.
make configure
./configure --prefix=/user
sudo make install install-doc install-html install-info
Step 6 : Verify installation
Once, installation is done, verify installation using git -v command.
git -v
How To Install Git on Ubuntu 20.04 – FAQs
How do I keep git updated?
If you used Method 1, simply run sudo apt update && sudo apt upgrade regularly. For Method 2, download the latest source code, recompile, and install.
Is there another way to install Git like GUI?
While Git itself is a command-line tool, there are graphical user interface (GUI) clients available for Git. These clients provide a visual interface to interact with Git repositories.
Can I use same steps on Ubuntu based distributions?
Yes. These steps will work on any Ubuntu based distributions like PopOS, Linux Mint, Kali Linux etc.
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.