Today in this tutorial will get to know how to install and configure Git on Debian 10.
Nowadays, Git is the most famous version control system, as it supports distributed architecture and functionalities, we called it distributed version control system. It used by much more open source and commercial projects.
It has the functionalities to track the code changes, create branches, revert the project to previous stages, and collaborate with team members and your fellow developers.
Linus Torvalds was the first person who initiated the Git project and developed it; He is the person who creates the Linux Kernel also.
I have done all stuff on Debian 10 what written in this article but hope it will also work on any previous Debian System.
Before continue with below process to install Git, make sure your operating system is Debian 10, and you have logged in as a user who is having sudo privileges.
Install Git with the APT package manager
The recommended and easiest way to install Git into the Debian system is by using the native package manager (APT) from the default repository of Debian Operating System.
This process will install the Git with the version available in the Debian repository but if you want to install any other version or latest version of Git, follow the process of Installing Git from Source tutorial.
You can install Git into Debian System using APT package by following steps:
Step 1- Update Debian repository’s package index
Always update the repository package index before installing the new package in the system.
Step 2- Installing Git
Once the repository package list is get updated you can start Git installation by using the following command:
Step 3- Verify and check the installed version of Git
You can verify the new application installation by checking the version by running the command; here we are checking Git installed version using the following command:
Now, Git version 2.11.0 successfully installed in your system; Now you can move into the Git configuration tutorial to complete your setup.
Installing Git from Source
You can use Source installation for Git as another option of installation for Debian Operating system. By using this installation, you can use the latest version or any version you like.
The only drawback of source installation is not being able to maintain using the APT package manager.
In the Linux operating system, when you use a package manager to install any application, it will install all required dependencies automatically, but when you use source installation, you need to install all dependencies manually.
So, first, update the package list and install all dependencies for Git on Debian system using the following command.
After installation of all dependencies go to the Git project on GitHub and copy the package link that ends with .tar.gz:
I have got the latest version 2.22.0 at the time of writing this article as you can see in the above picture.
Now download the Git source file in the /usr/src directory. Generally, we kept all source files at this location, to do this first need to change the directory with the following command:
Now you can use the wget command to download the Git source file with name git.tar.gz, as shown below:
Once the file gets downloaded, the file needs to extract and get into the new directory.
Now, before installation needs to compile the source files by using the following command:
After completion of a successful compilation, you can install git using this command:
When you get the prompt after successful completion of Git installation, you should add folder location into PATH variable and verify it by checking the version of installed Git, as shown below:
There is the only problem with source installation is when you want to upgrade on latest version again you need to repeat the installation process.
After installation of Git version control system needs to set up the email and username for Git commit, you can do it by using the following command:
When the above operation for setting the email ID and username you can verify by using the following command:
The configuration saved into the ~/.gitconfig file:
If you want to make a change in this configuration, you can use the git config command or edit the ~/.gitconfig file manually.
Now you have learned Git Version control system installation on Debian Operating system; you can also check highly recommended book on git – Pro Git to learn more about Git.
If you get any problem while installing Git into your system or have any feedback about this article, leave a comment below.