How To Install Git On Ubuntu 22.04 LTS In 2024
Git is a free and open-source distributed version control system. Here, You can find the step by step guide to install Git on Ubuntu 22.04 LTS.
How To Install Git On Ubuntu 22.04 LTS In 2024
Make sure that all of the packages installed on Ubuntu 22.04 are up to date before beginning the Git installation on Ubuntu. To find out if the packages are current, run the following command.
apt update -y
For the most part, the git package ought to be installed by default on Ubuntu 22.04 LTS. To find out whether you have git installed or not, run the following command. This command will show you the version of git that is presently installed on your system if you already have it installed.
git --version
Output
git version 2.34.1
In case the git package isn’t installed, Run the following command in your Ubuntu.
apt update
apt install git
Enter ‘Y’ to continue the installation.
To verify whether the installation was successful or not, Run the git –version command again.
Just in case 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 In 2024
Installing git from the source will allow you to install the most recent or alternative version of the software. Run the following commands one by one to update the packages and install all the dependencies that is needed.
apt update
apt install libz-dev libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext cmake gcc
You can check the webpage https://mirrors.edge.kernel.org/pub/software/scm/git/ if you’re unclear about the version. and you have the option of installing a different version of git. Once the version check is complete, Run the following command to download Git.
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz
Now unpack the compressed tarball file:
tar -xzf git-2.9.5.tar.gz
Next move to the git directory:
cd git-2.9.5
Now, it’s time to install git on Ubuntu.
make prefix=/usr/local all
make prefix=/usr/local install
exec bash
Run the following command to check if the installation was completed or not in your system.
git --version