If you are looking for a powerful VCS or Version Control System, look no further because Git is exactly what you require. Git is a magical DVCS or Distributed Version Control System that allows users to manage or track changes in code, files, or projects. It is secure and highly efficient as it uses unique fingerprints that make it impossible for malicious code insertion in your project. Git is cross-platform and almost every operating system supports it. Git is also pre-installed in most operating systems, such as Ubuntu 24.04, but for some reason, users may want to use a specific version of Git.

After going through this guide, you will master installing Git on Ubuntu 24.04 and utilize the version-specific feature.

How to Install Git on Ubuntu 24.04

To install Git on Ubuntu 24.04, try either of the following methods:

  • Using the apt Command.
  • From the Source.

Method 1: Install Git on Ubuntu 24.04 

Since the Git is pre-installed on Ubuntu 24.04, you need to check if it is installed on your system first via the following command:

git --version

The above output shows that Git is pre-installed, but if it is not installed on your system, execute the below-stated command to install Git on Ubuntu 24.04 from the official repositories: 

sudo apt install git

Method 2: Install Git on Ubuntu 24.04 From the Source

If you want to install a specific version of Git on Ubuntu, you can use the Source. But in doing so, you must install the required libraries by running the following command:

sudo apt install build-essential libz-dev libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext cmake gcc -y

Now, create a temporary directory called tmp:

mkdir tmp

Next, navigate to the tmp directory, download the Git Tar.gz file using the below-stated commands, and replace 2.38.0 with the version you want to install:

cd /tmp
curl -L https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.38.0.tar.gz -o git.tar.gz

Now, extract the downloaded git.tar.gz file:

tar -zxf git.tar.gz

Next, navigate to the extracted directory and make the Git package by executing the following commands:

cd git-*
make prefix=/usr/local all

Finally, install the specified Git version on Ubuntu 24.04 by executing the below-mentioned command:

sudo make prefix=/usr/local install

At last, replace the current shell process so that it recognizes the newly installed Git version on Ubuntu 24.04:

exec bash

Now, confirm the installation of Git on Ubuntu 24.04 via the following highlighted command:

git --version

How to Configure Git on Ubuntu 24.04

To be able to use Git on Ubuntu 24.04, you must configure it. To do that, execute the following commands to add Your Username, Your Email Address and view the changes:

git config --global user.name "Your Username"
git config --global user.email "Your Email Address"
git config --list

You can do these configurations in the ~/.gitconfig file as well. To do that, open the ~/.gitconfig file and specify the name and email address:

nano ~/.gitconfig

Note: This username and email address are the same as the one you use to log in to GitHub.

After configuring Git on Ubuntu 24, you can use various Git commands right from the Terminal. The common Git commands are briefly explained as follows:

The git init Command

The “git init” command initiates a new repository in the currently navigated directory.

The git clone Command

This command lets you clone an existing Git repository from a working URL/address.

The git status Command

It lets you view the current status of the working directory and the staging area.

The git add Command

The “git add” command allows you to add a file to the staging area for version control.

The git commit Command 

The “git commit” command when executed, triggers the process to record the changes made in the currently navigated directory.

That’s all for installing Git on Ubuntu 24.04.

Final Words

To install Git on Ubuntu 24.04, execute the command “sudo apt install git” or you can also install a specific Git version as well. To install the specific Git version on Ubuntu 24.04, download its tar.gz file, make its installer, and install it. 

You can configure Git via the Terminal and ~/.gitconfig file to add your username and email address. This guide has discussed the methods to install Git on Ubuntu 24.04 and also illustrated its basic configurations.