How to install Git on Debian 10?

A software developer requires many tools to help him with the process. One of these tools is the Software version control systems like git. Thanks to this tutorial, you will learn how to install Git on Debian 10.

Git is an open-source software version control system and cross-platform that will help you version the program you developed. Thanks to this program, you can track changes in the software, as well as reverse it or make a new version of it. And much more.

Thanks to the ease of use, the great community behind it, and its robustness, Git has become incredibly popular. Many commercial applications use Git in development.

On the other hand, Git is used by many open-source projects that host the source code in solutions like Github or Gitlab. This is because Git allows for online collaboration through versioning of the software.

As is well known, Debian 10 is a robust operating system used by many developers to create their applications. So it is a good idea to know how to install Git on this system.

In this post, I will show two different methods to get to the goal of installing Git. Each one has its advantages, but you only have to choose one. So do not use both because it can create problems.

Install Git from the Debian repositories

One of the main advantages of Git is that it is incredibly popular. This makes the major Linux distributions include it in their official repositories. And so does Debian.

To be sure, open a terminal and run the following command:

:~$ sudo apt search git
Git on the Debian repositories
Git on the Debian repositories

As you can see, there are many packages related to Git. But you can also notice that the Git package is available.

So to install it, you just run this command:

:~$ sudo apt install git
Installing Git on Debian
Installing Git on Debian

After you type in your password and confirm the installation, it will start.

Once the installation is complete, you can check the installed version.

:~$ git –version
git version 2.20.1

And that’s how Git will be installed on Debian 10.

Install the latest version of Git on Debian 10

The above method is very easy to do and even beginners may like it more. However, there is a small downside to it and that is that you do not get the latest version available.

For example, at the time of writing, the latest stable version of Git is 2.26 but Debian includes 2.20.

So, it’s possible that if you develop software you want the latest version of Git. This is to take better advantage of the new features and novelties that the application has.

At the same time, the best way to get the latest stable version of Git on Debian 10 is to manually compile the application’s source code.

First, it installs the packages needed to build new packages and other necessary libraries.

:~$ sudo apt install build-essential make unzip libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev gettext dh-autoreconf libz-dev
Install packages build from the source code
Install packages build from the source code

These packages also bring many others but which are necessary to compile code in Linux. Also included is the unzip package to unzip the zip file.

Now the next step is to download the Git source code. Do this from the /tmp folder

:~$ cd /tmp/

Then, start the download using the git command.

:~$ wget https://github.com/git/git/archive/v2.26.0.zip -O git.zip

The above command will generate a file called git.zip that is where the source code for Git is. This file, you have to unzip it.

:~$ unzip git.zip

As a result of the file decompression, a folder called git-2.26.0 will be created and accessed.

:~$ cd git-2.26.0/

Once you’re in the folder with the source code, you have to compile it. This process will take a while depending on your computer. In any case, it’s not much either.

:~$ sudo make prefix=/usr/local all
Building Git package

After the compilation process is complete, you can install Git. To do this, run the following command:

:~$ sudo make prefix=/usr/local install
Install the latest version of Git
Install the latest version of Git

Once the installation process is complete, you can check the operation of the git command by displaying the installed version.

:~$ git --version
git version 2.26.0
Git installed on Debian
Git installed on Debian

How do I upgrade Git manually?

The development of Git is very active. This means that frequently, a new version is released. If you have installed Git using the old method, you can keep it up to date with the following steps.

Once you have git installed, you can update the version installed on your system.

To do this, navigate to your home folder and clone the Git repository using Git.

:~$ git clone https://github.com/git/git.git

Then, browse to the generated folder and compile the code again.

:~$ git cd
:~$ make prefix=/usr/local all

Finally, install the new version of Git.

:~$ sudo make prefix=/usr/local install

This way you can always have the latest stable version of Git. It takes some work, but it is worth it.

Configuring Git for the first use

Git is set up to work when you install it, but it’s a good idea to do a little configuration to avoid problems with commits.

In particular, you need to define a name and e-mail address so Git knows who is making changes to the software. This is to help you collaborate.

To do this, you use the git config command along with some parameters:

:~$ git config --global user.name [your-name]
:~$ git config --global user.email [your-email]

This way it will already be defined in the Git configuration. To check it out, run the following command:

:~$ git config --list

Now, Git is ready to work.

Conclusion

Software development is a process that requires many tools together to achieve a goal. An important element is version control that makes the code tidy.

Git emerges as one of the most solid proposals with a high spirit of efficiency. Not surprisingly, its initial developer was Linus Torvalds.

So now you know how to install Git on Debian 10, how has your experience been with it? do you use it a lot?

Scroll to Top