blog-image

Nov 22, 2024

17 min read

Full Guide: How To Install Git on Debian 12 and Use it

Written by

Abdelhadi Dyouri
Looking for a detailed guide on how to install Git on Debian 12 and use it for version control on your server? This is the article you’ve been looking for. Git and version control is probably the most important part of software development these days, and Debian is one of the most widely used operating systems among developers. No matter your current expertise level in software development, learning to use Git is extremely important for good collaboration and project management. In this guide, I'll walk you through the process of installing and configuring Git on Debian 12 in a few steps. Install Git on Debian 12

Prerequisites

Before you install Git, you need:
  • A Debian 12 server. Get your VPS hosting from a reputable and trustworthy provider like SSD Nodes. We offer powerful Debian servers and the best deals. Take a look at our offerings and prepare for your mind to be blown 🤯.
Check out our How to access your server using SSH guide to learn how to access your server and create a sudo user.

Step 1: Updating the System Package List

Start by updating the packages in the package manager cache to the latest available versions using the following command:
sudo apt update

Step 2: Install Git on Debian 12

Debian offers two primary ways to install Git:
  1. Through the APT package manager, which is simpler and faster.
  2. Compiling Git from source (which provides more control over the version you install). We'll cover both methods below.

Install Git Using APT

The easiest way to install Git on Debian 12 is by using the APT package manager. This method installs a stable version of Git directly from Debian’s official repositories. Here’s how to do it:
sudo apt install git
Once the installation is complete, you can verify the version of Git installed by running:
git --version
Output:
git version 2.39.5
At this point, Git should be ready for use. However, if you need a more up-to-date version, you can install Git from source. To do this, follow the instructions outlined in the next section.

Install Git From Source

If you need the latest version of Git or want to customize the installation, you can compile Git from source. This method requires a few additional steps, but it allows for greater flexibility. First, install the necessary dependencies:
sudo apt install wget dh-autoreconf libcurl4-gnutls-dev libexpat1-dev \
  gettext libz-dev libssl-dev asciidoc xmlto docbook2x install-info build-essential
Next, download the latest Git source code. Visit the Git release page and find the latest version: Git latest version Next, use the following command to download and extract it (replace 2.47.0 with the latest version number):
wget https://www.kernel.org/pub/software/scm/git/git-2.47.0.tar.gz
tar -zxf git-2.47.0.tar.gz
cd git-2.47.0
Now, generate the configuration script for Git:
make configure
Output:
GIT_VERSION = 2.47.0
    GEN configure
Run this configuration script, specifying that the Git binaries should be installed under the /usr directory:
./configure --prefix=/usr
The output will inform you that the checks are done and the configuration files are created:
configure: creating ./config.status
config.status: creating config.mak.autogen
config.status: executing config.mak.autogen commands
Compile Git and build the documentation:
make all doc info
Finally, install Git, along with its documentation:
sudo make install install-doc install-html install-info
Verify that Git was installed successfully:
git --version
You should see a version that matches the tarball you’ve downloaded:
git version
Continue reading this article
by subscribing to our newsletter.
Subscribe now

A note about tutorials: We encourage our users to try out tutorials, but they aren't fully supported by our team—we can't always provide support when things go wrong. Be sure to check which OS and version it was tested with before you proceed.

If you want a fully managed experience, with dedicated support for any application you might want to run, contact us for more information.

Leave a Reply