How To Install Git On Ubuntu 22.04 LTS [2023]

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 [2023]

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.

 git --version
Output
git version 2.34.1

If the git package is not installed, run the following commands in your Ubuntu 22.04 LTS:

apt update
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 update
 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.

 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

 git --version
READ More Relevant Stuff:  How To Uninstall Software from Terminal in Ubuntu

Leave a Reply

Your email address will not be published. Required fields are marked *