Debian

How to Install Git on Debian 11 Bullseye

Git is a free and actively maintained distributed version control system that effectively manages minor to major projects. People use it for source code management on the software development side since it allows project developers to collaborate. On the other hand, the other developers can track the modification in the source code uploaded by a developer on the Git server and receive alerts if any modification is done to the code.

This article is a detail guide to install Git on Debian.

How to Install Git on Debian

You can install Git on Debian from the following two methods:

Method 1: Install Git from Debian Repository

The Debian repository includes the Git repository, allowing users to install it on Debian through the “apt” command. However, since we are installing Git from the source repository, it’s a good to update the Debian packages list from the following command:

sudo apt update && sudo apt upgrade -y

Now, install Git on Debian from the following command:

sudo apt install git -y

Check the Git version on Debian from the following command to confirm its installation:

git --version

From the above-given method, you won’t be able to install the updated version of Git on Debian.

Method 2: Install Git from GitHub Source

To install the Git latest version on Debian, the users must follow the below-given steps:

Step 1: Download Prerequisites

First, you must install some prerequisites on Debian from the following command:

sudo apt install make libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev libssl-dev gettext -y

Step 2: Download Git tar.gz File on Debian

Now, the Git latest version tar.gz file on Debian from the following command:

wget https://github.com/git/git/archive/refs/tags/v2.39.2.tar.gz

Ensure to download the latest version from here.

Step 3: Extract tar.gz File

To extract Git content on Debian, run the below-mentioned command:

tar -xf v2.39.2.tar.gz

Step 4: Setting up Git for Debian

Navigate to Git source directory on Debian:

cd git-2.39.2

Compile the Git files from the following command:

sudo make prefix=/usr/local all

After completing the compilation, you can perform Git installation on Debian from the following command:

sudo make prefix=/usr/local install

Step 5: Check Git Version on Debian

After completing the installation, close the terminal and reopen again. Then use the version command to confirm the installation of Git’s latest version on Debian.

git --version

The above confirms that the method successfully installed Git’s latest version on Debian.

Conclusion

The Git installation on Debian is simple from the source repository and requires only a single command. However, the method won’t install the updated Git version. The updated Git version can only be installed by downloading the latest tar.gz source file, extracting the files, and compiling them through the make command. The process may take time, but it will successfully install the latest Git version on Debian.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.