May 13, 2025
Tutorials

How to Install and Configure Git on Debian 12

Install and Configure Git on Debian 12

Git is an actively maintained open-source software tool known as a distributed version control system. It is responsible for managing changes in the software code. It is widely used in source code management for software projects of any complexity. Git can monitor any changes made to code files and their related versions. The developers use Git’s service to control the code repository, collaborate and examine tiny bits of code that are altered.

In the setting of Debian 12 and other Linux systems, you can use Git to pull out source codes from GitHub by issuing the git clone command. Such practices are popular with Linux users who wish to install applications not available in the official repository of the system.

In this guide, you will find:

How to Install Git on Debian 12

You can install Git on Debian 12:

How to Install Git on Debian 12 from Apt Package Manager

Git can be installed in the system since its package is in the Debian 12 repository. However, the version of Git installed is not the most up-to-date one. This is because it is installed through apt.

Step 1: Update System Repositories

To make sure all packages are current, run the following command:

sudo apt update && sudo apt upgrade -y

sudo apt update && sudo apt upgrade -y

Step 2: Install Git

After the repository of Debian 12 has been updated, Git may be installed with the command:

sudo apt install git -y

sudo apt install git -y

Step 3: Check the Installed Git Version

to verify the installation was successful, you can check the Git version with the:Important: If you do not wish to utilize the Git version obtained from the apt repository, you may exclude it from this command:

git –version

git --version

Important: If you do not wish to utilize the Git version installed through the apt repository, you may uninstall it using the following command:

sudo apt remove git -y

sudo apt remove git -y

How to Install Git on Debian 12 Using tar.gz Source File

To install the latest version of Git on Debian 12, you are required to visit GitHub in order to download its tar.gz source file and subsequently configure its contents to finalize the installation. To perform the installation of Git on Debian 12 via the tar.gz source file, follow the step-by-step guide below:

Step 1: Install Prerequisite Packages

Prior to installing Git on a Debian 12 system, ensure to run the following command as it will assist in ensuring the following dependencies are completed beforehand:

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

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

Step 2: Download Git

No, we first go to the Git download page and obtain the Git latest version tar.gz source file from Debian 12. Alternatively, you may download the file directly through the wget command together with the URL for Git’s latest version.

As of the time of writing this blog, Git’s latest version is 2.44.0, which you are able to obtain on Debian 12 through the command:

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

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

Step 3: Extract the tar File

After downloading the Git source file, you may extract its contents by executing the tar command with the -xf parameter followed by the source file name:

tar -xf v2.44.0.tar.gz

tar -xf v2.44.0.tar.gz

Step 4: Configure Git Installation Files

Now, to set Git’s installation files on Debian 12, you can do so by executing the command below in your terminal.

cd git-2.44.0

cd git-2.44.0

Start the configuration and proceed to execute the command:

sudo make prefix=/usr/local all

sudo make prefix=/usr/local all

After the configuration is complete, proceed to execute the command below in your terminal to install Git’s most current version on Debian 12.

sudo make prefix=/usr/local install

sudo make prefix=/usr/local install

Step 5: Check the Git Version on Debian 12

To check if Debian 12 has the most recent version of Git, one only needs to execute the command below.

git –version

git --version

Note: To remove Git that was installed using the tar.gz source, use the following command to browse to the source directory where Git was installed:

which git

which git

Then run the following command to erase the directory containing the sources of Git from your Debian 12 machine:

sudo rm /usr/local/bin/git

sudo rm /usr/local/bin/git

This will remove Debian 12’s access to Git.

How to Configure Git on Debian 12

The first thing to configure after installing Git on Debian 12 is setting your username and email address. This is essential for accurate tracking method authorship attribution and consistent identification.

Setting Username

For Debian 12, to configure Git, run the following command in the terminal and replace Git_username with your defined user:

git config –global user.name “Git_username”

git config --global user.name "Git_username"

Setting Email Address

Then, use the following command to replace email@gmail.com with the desired email address to set the address associated with the username you added.

git config –global user.email “email@address.com”

git config --global user.email "email@address.com"

Verification

To check the Git configuration, use the following command:

git config –list

git config --list

Git Manual

There are some basic steps which I have described above. To broaden your knowledge regarding the utilization of Git on your system, you may consult the Git manual with the command:

man git

man git

That is all from this article.

Conclusion

Git is an ideal application for all users who want to manage their files since it maintains track of changes made to the source code. On Debian 12, you may install Git using either the apt package manager or through a tar.gz source file.

Using apt is rather straightforward, requiring only one command to install Git. The downside is that Git may not be the most up-to-date version after installation. Using the tar.gz source file can be more complex, but it ensures that the most recent version of Git is installed on Debian 12. In the end, the Git installation method you choose on Debian 12 should suit your needs. Regardless, you need to learn with the steps outlined for installation and configuration in Git’s documentation.

Frequently Asked Questions

Use the command sudo apt update && sudo apt install git to install Git from the official Debian repositories.
Run git --version in the terminal. It should display the installed Git version.
Use git config --global user.name "Your Name" and git config --global user.email "you@example.com".
Global settings are in ~/.gitconfig. Local settings are in the .git/config file inside each repository.
Use git config --global core.editor nano (or replace nano with your preferred editor).

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video