Git, a version control system, can be utilized by software developers to enable their teams for managing their codebase. The developers can track the changes made in their codebase using Git.
Git is a lightweight platform and also ensures the integrity of the data by using SHA-1 to manage the data. Git can be installed on Debian 12 by using various methods which are explained in this post.
What are the Installation Methods on Debian 12 for Git Package?
The installation of the Git is done in one of two ways:
Method 1: Install Git on Debian 12 Using the Default apt Package Manager
The first recommended method to install packages on Debian 12 is by using the apt package manager. Git can be installed by following the below-mentioned commands.
Step 1: Update the Packages
Update all the packages to ensure that the updated package of Git should be installed:
$ sudo apt update
Step 2: Install Git
Now, install the package of Git:
$ sudo apt install git -y
Step 3: Verify the Installation
After installing the Git, verify the installation by displaying its installed version:
$ git --version
How to Uninstall Git on Debian 12?
To remove and uninstall the package Git on Debian 12, use the command:
$ sudo apt purge git -y
Method 2: Install Git on Debian 12 Using its Source Package
To install the updated release of Git on Debian 12, download its source code and compile it to install it by the following commands.
Step 1: Download the Source Code
First, install the dependencies by executing the command:
$ sudo apt install build-essential libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext
Now, download the source code of the latest release of the Git:
$ wget https://github.com/git/git/archive/refs/tags/v2.41.0.tar.gz
Step 2: Extract the Downloaded File
Next, extract the downloaded tar file:
$ tar -xf v2.41.0.tar.gz
Step 3: Navigate to the Git Directory
After extracting the git package, downloaded its directory:
$ cd git-2.41.0
Step 4: Compile the Source Code
Compile the extracted source code in the previous steps by building it:
$ make configure && ./configure --prefix=/usr/local && make all
Step 5: Install Git
Finally, install the Git package:
$ sudo make install
Step 6: Verify the Installation
For the verification of Git’s installation, display its version:
$ git --version
How to Use the Git on Debian 12?
The basic commands of Git for the management of version controls are explained.
Initialize the Git Repository
In the current directory, a new repository of Git can be initialized using the command:
$ git init
Clone a Repository
To clone a remote repository to our local machine:
$ git clone https://github.com/example/repo.git
Display the Status
Use the command to display the status of the current directory and staged amendments:
$ git status
Log of Git
Display the log of the Git commands:
$ git log
To learn more git commands, follow this mentioned article.
That’s all about the installation and usage of Git on Debian 12.
Conclusion
To install the git on Debian 12, update the packages using the “sudo apt update” and then install with “sudo apt install git -y”. Another installation method for Git on Debian 12 is by compiling the source code methods. Both these methods of installing Git have been explained in this blog.