Git is a renowned open-source distributed version control system widely used by developers for managing code across projects of all scales. With Git, developers can easily host their code on popular platforms like Github, BitBucket, and Gitlab, simplifying code management tasks such as version control and branching.

Its versatility and efficiency make it a preferred choice for many software projects, but in order to use it, you first have to learn how to install Git on Debian 11 in this case, or any other OS that you need it on. While installation is similar on most Linux distributions, in this article we will focus on Debian 11.

One of the notable advantages of Git is its user-friendly nature and ease of comprehension. It boasts a small footprint and delivers lightning-fast performance, outperforming other software configuration management (SCM) systems like Subversion, CVS, Perforce, and ClearCase. Git offers a range of advanced features, including low-cost local branching, convenient staging areas, and a plethora of operations, making it an indispensable tool for collaborative development.

When wanting to install it, you have two options: using the APT package manager to install Git from the Debian repositories or opting for a direct installation from the source, which ensures access to the latest version of Git.

Let’s dive in and explore how to install Git on your Debian 11 bullseye system, enabling you to leverage its powerful version control capabilities for your software projects.

How to install Git on Debian 11

A little note if you are a new Debian user. Your instance might not have “sudo” installed and that’s perfectly fine. In our guide, we assume that you have sudo and that you not logged in as a root, but in case you get something like “-bash: sudo: command not found” fear not.

In order to follow our guide, enter root mode by command “su -“. It will ask you for a password(you wont see it while its being typed).

After that, just run the command we listed on this page without “sudo”, for example instead of “sudo apt update” you will run “apt update”.

First way(and the easier) – Using APT

Step1 – Installing updates

how to install git on debian 11 - step1

For this tutorial, we have started up one of our awesome KVM VPS machines and installed Debian on it. Usually when you just install a system on your machine, weather its your computer or VPS, you need to run some updates else you will encounter some problems.

Even if it isn’t your first time booting into your system, chances are you didn’t update it for quite some time.

Lets do that now. Run the following command and get yourself a cup of coffee while waiting. We definitely will.

sudo apt update && sudo apt upgrade -y

If you are wondering what “-y” indicates, its a flag that will automatically answer “yes” to any prompts during the upgrade process allowing you to do whatever else you want while its running. It’s useful considering that sometimes upgrade can take some time.

Step 2 – Installing GIT on Debian 11

Once that is done, we are almost done, at least in regards to the installation itself. Installing GIT on Debian 11 with APT is pretty simple, just run the following command and wait a little:

sudo apt install git

After that is done, let’s confirm that it was installed by running:

git version

Nice, we got 2.30.2!

Second way – Installing Git on Debian 11 from the source

Now, why would you do it this way?

The most simple answer is that maybe you want the most recent version of git that isn’t available through the apt. It’s longer and might be more complicated, but it has no downsides really and its a great chance to learn something new.

Step 1 – Install all dependencies

sudo apt-get update

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

After running these two commands, we are jumping to the harder part. It’s not really that hard, but if you never did it, it may seem a little scary. We still encourage you to go through this process with us!

Step 2 – Download the files

We will use this official Git publish repository. Run the following command to download master.zip in your current directory:

wget https://github.com/git/git/archive/refs/heads/master.zip

Now let’s unzip this by running:

unzip master.zip

By typing “ls” you should be able to find “git-master” directory. Lets move to it now:

cd git-master

And now run these two commands to install it:

sudo make prefix=/usr/local all

sudo make prefix=/usr/local install
how to install git on debian 11 from the source

First command may take some time. Be patient and in the meantime feel free to explore our Dedicated Server options that are both affordable and powerful. Our clients love them!

After everything is done, by running “git -version” we got “git version 2.41.GIT”.

As you can see, the apt didn’t give us the latest version. By no means is that bad, the apt versions are usually the most stable ones, but that doesn’t stop us from using the latest ones if we want to.

We hope that you have found this tutorial useful and that it have guided you properly through this process. We are always listening to our readers and so if you have any suggestions, let us know.

Until next time!

Similar Posts