Today in this tutorial will get to know how to install and configure Git on Debian 8 Linux.
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 8 what written in this article but hope it will also work on any Debian System.
Before continue with below process to install Git, make sure your operating system is Debian 8, and you have logged in as a user who is having sudo privileges.
Install Git with 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
$ sudo apt-get update or $ sudo apt update
$ sudo apt-get install git Or $ sudo apt install git
$ git –version
Output: git version 2.11.0
Now, Git version 2.11.0 successfully installed in your system; Now you can move into the Git configuration tutorial to complete your setup.
Install 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.
$ sudo apt update $ sudo apt install make libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip
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:
$ cd /usr/src/
Now you can use the wget command to download the Git source file with name git.tar.gz, as shown below:
$ sudo wget https://github.com/git/git/archive/v2.22.0.tar.gz -O git.tar.gz
Once the file gets downloaded, the file needs to extract and get into the new directory.
$ sudo tar –xzf git.tar.gz $ cd git-*
Now, before installation needs to compile the source files by using the following command:
$ sudo make prefix=/usr/local all
After completion of a successful compilation, you can install git using this command:
$ sudo make prefix=/usr/local install
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:
$ sudo export PATH=$PATH:/usr/src/git-2.22.0 $ git --version
Output: git version 2.22.0
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:
$ git config - -global user.name “Your UserName” $ git config - -global user.email “Your email ID”
When the above operation for setting the email ID and username completed, you can verify by using the following command:
$ git config --list
Output: user.name=satish [email protected]
The configuration saved into the ~/.gitconfig file:
[user] name = satish email = [email protected]
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 8 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, feel free to leave a comment below.