Debian

How to Install Git on Debian 12

how to install git on debian 12

Git is a free, open-source, distributed version control system used for tracking changes to source code and documents during software development as well as coordinating work among programmers. This article will describe how to install Git in Debian 12 (Bookworm) systems.

How to Install Git on Debian 12?

Git can be installed using the below-listed methods:

  • Method 1: Installing Git Using Default APT Package Manager
  • Method 2: Installing Git from tar.gz Package

Method 1: Installing Git Using Default APT Package Manager

APT (Advance Package Tool) is Debian’s default package manager. Git can be installed using the apt package manager by the following steps:

Step 1: Launch Terminal

The first step is to launch Terminal. It can be launched either by using the shortcut Ctrl+Alt+T or by using the Application launcher.

All applications, system components, and files installed on the system are placed in the Application launcher. Terminal can be launched by application launcher by pressing the Activities button in the left corner of the screen, then by typing “Terminal” in the search bar and by selecting the Terminal icon:

The following screenshot shows how the Terminal application looks like on Debian:

Step 2: Update APT Sources/Packages

We will update the apt repository before installing any new software with sudo privileges to avoid dependency issues by running the following command:

$ sudo apt update

Step 3: Install Git

The latest stable version of git can be installed by running the following command:

$ sudo apt install git

Press “Y” at the prompt to continue with the installation process. The installation is completed. In the next step, we will verify the installation.

Step 4: Verify Git Installation

To verify the installation, we can check the Git version by running the following command:

$ git --version

Method 2: Installing Git from tar.gz Package

The .tar.gz is a popular compressed archive file format for Linux systems. It is a combination of two archive formats (tar and gzip). We will use the following steps to install git from a tar.gz archive:

Step 1: Download tar.gz file (git-2.41.0.tar.gz)

First, we will access the Git Website and click on the “Download for Linux” button:

This will redirect to a web page containing information about downloading Git for Linux and Unix. We will select “on kernel.org” to access the Tarballs:

We will be redirected to a page containing .tar.gz files of all of its earlier versions. We will search for the .tar.gz file for the latest version, i.e., 2.41.0 (release date: 2023.06.01) by using the shortcut key “Ctrl+F” and will download the git-2.41.0.tar.gz file:

This file will automatically be downloaded in the “Downloads” folder:

We can verify it by navigating to the Downloads folder using the “cd” command as shown below:

Step 2: Install Additional Packages

Before proceeding with extraction and installation, we will be required to install additional packages: autoconf, libz-dev, install-info, and asciidoc. We will install these packages one by one by running the following commands:

$ sudo apt install autoconf

Press “Y” at the prompt to continue with the installation process. After autoconf is installed, we can proceed with the installation of libz-dev by running the following command:

$ sudo apt-get install libz-dev

$ sudo apt install install-info

$ sudo apt install asciidoc

Press Y at the prompt to continue with the installation process. After the installation of these additional packages is completed, we can proceed with the extraction of the .tar.gz file.

Step 3: Extraction of git-2.41.0.tar.gz archive file

We can extract the tar.gz file (git-2.41.0.tar.gz) by running the following command:

$ tar -zxf git-2.41.0.tar.gz

From the above screenshot, it can be seen that the git-2.41.0.tar.gz file is extracted.

Step 4: Building and Compiling the Source Code

After extraction of the file, we will build and compile the source code. For that, we will navigate to the git-2.41.0 directory using cd and configure by running the commands below:

$ cd git-2.41.0

After that, use the “ls” command to display the “configure” file/folder:

$ ls

$ make configure

$ ./configure --prefix=/usr

$ make all doc info

Step 5: Install Git

After successful compilation in the previous step, we will run the following command to install git:

$ sudo make install install-doc install-html install-info

Step 6: Verify Installation

We can verify Git installation by using the following command:

$ git --version

How to Uninstall Git on Debian 12?

If in case, we need to uninstall git along with deleting configuration and data files of git and its dependencies from our system, we can run the following command:

$ sudo apt-get purge -–auto-remove git

Press “Y” at the prompt to continue with the uninstallation process:

That is all from the guide.

Conclusion

To install git on Debian 12, users can use the default apt package manager by installing it from a source package. Both are efficient methods. Git is very popular in the developer community. It provides features like tracking changes in source code/documents and enables collaboration between software developers/coding teams. This article discussed two methods of installing git on Debian 12 (Bookworm) systems, i.e., by using the default apt package manager and by installing from a source package.

 

Similar Posts