Last Updated on January 31, 2023 by itsubuntu
How To Install Git On Ubuntu 22.04 LTS
In this tutorial post, we will show you the ways to install Git on Ubuntu 22.04 LTS. Git is a free and open-source distributed version control system.
How To Install Git On Ubuntu 22.04 LTS 
Before starting the installation of Git on Ubuntu, we need to make sure that all packages installed on Ubuntu 22.04 are up to date. Run the following command to see whether the packages are up to date or not.
apt update -y
In most cases, Ubuntu 22.04 LTS should have the git package installed by default. Run the following command to check if you have git installed or not. If you already have git installed on your system, this command will display the version of git you currently have installed on your system.
Output git version 2.34.1
If the git package is not installed, run the following commands in your Ubuntu 22.04 LTS:
apt install git
Enter ‘Y’ to continue the installation.
To verify whether the installation was successful or not, you can run the git –version command again.
Meanwhile, if you want to install a different version of Git then run the following command to check which git version is available to install.
apt-cache policy git
How To Install git from Source On Ubuntu 22.04 LTS
If you want to Install the latest or different version of git then you can do it by installing git from the source. Run the following commands one by one to update the packages and install all the dependencies needed.
apt install libz-dev libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext cmake gcc
If you are confused about the version, you can visit the website https://mirrors.edge.kernel.org/pub/software/scm/git/ and you can choose which git version you want to install. Now, after finalizing the version, run the following command to download Git.
Now unpack the compressed tarball file:
tar -xzf git-2.9.5.tar.gz
Next move to the git directory:
Now, it’s time to install git on Ubuntu.
make prefix=/usr/local all
make prefix=/usr/local install
Run the following command to check if the installation was completed or not
Leave a Comment