Debian

How to Install and Configure Git on Debian 11

Git is the popular open-source distributed version control management tool. This tool handles everything related to the code from small to large projects. This tool allows the developers to host their codes on famous sites like GitHub. Git is also a secured tool, all the files and directories in Git are secured by the SHA1 (secure hashing algorithm). This tool can be installed on almost every operating system including Debian.

In this detailed guide, we have demonstrated how to install Git on Debian 11.

Install Git on Debian 11

The following are the ways to install Git on Debian 11:

Method 1: Install Git Using the apt

The Git is present in the default repository of Debian, you can easily install it on the system using the single command. Before installing Git, update and upgrade your system via the apt command as shown below:

sudo apt update && sudo apt upgrade

Once the system is up to date, execute the below-given command to install Git on Debian 11:

sudo apt install git

After the successful installation of Git, run the version command to check if it’s properly installed on the system or not:

git --version

Method 2: Install Git Using the Source

You can install Git latest version on Debian 11 through the source method that first requires installing the following dependencies on Debian 11:

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

Next, execute the following wget command to get the Git Zip file directly from the source:

wget https://github.com/git/git/archive/refs/heads/master.zip

Unzip the downloaded file by executing the following command:

unzip master.zip

Move to the git-master directory on the system:

cd git-master

The next step is to install the version controls the system from the source, for this first execute the following command:

sudo make prefix=/usr/local all

The above command will take some time, once it executed, run the following command to install the Git related files on the system.

sudo make prefix=/usr/local install

The Git latest version is installed on your Debian 11 and you can verify the installation via the following command:

Configure Git on Debian 11

Once the installation procedure is completed, you have to configure and set up Git on Debian 11. Execute the following command and replace the <linuxhint> with your name:

git config --global user.name "linuxhint"

Enter the email address to complete the configuration of Git:

git config --global user.email "[email protected]"

You can verify the modifications via the following command:

git config --list

All the configurations of the git are stored in the git config file which is in the home directory. To access the file, execute the following commands:

ls .gitconfig
cat .gitconfig

You can also edit the file by typing the following command in the terminal:

git config --global --edit

Remove the Git on Debian 11

To remove Git from Debian, enter the following command:

sudo apt remove --autoremove git

Bottom Line

Git allows the developers to use or collaborate with the source code, during the development of their programs. You can use Git to host your code on GitHub and it also facilitates the code management activities like branching. In the above section of the guide, we have listed the two ways to install Git on Debian. If anyone of the fails, you can try the alternate way. We have also mentioned the configuration and removal method of Git on Debian.

About the author

Zainab Rehman

I'm an author by profession. My interest in the internet world motivates me to write for Linux Hint and I'm here to share my knowledge with others.