Install & Configure Git on Debian 9

Introduction
Source control is a very important part of any software development process. Source control management systems are designed to keep history and revision information about the files and projects stored in a repository.
By storing this information, you'll have a complete history of everything that happened to the projects within the repository. In the event of a catastrophe, you'll be able to recover a previously saved version. Also, by saving your changes, you will be able to easily share your work with other developers and collaborate on projects regardless of location.
Git is a free and open-source distributed version control system. In other words, it's an application that keeps track of your code and all the changes that have been made to it in the past. Also, it allows you to share your code with others and collaborate on it without overwriting each other's changes.
In this article, we'll go over how to install and configure Git on a Debian 9 operating system.
Let's get started!
Table of Contents
Install Git Using the Package Manager
The quickest and easiest way to install Git is to use the default package repositories provided by your Linux environment.
First, we need to download the package lists from the repositories and update them to make sure we have all the latest information on the packages and their dependencies.
Open a terminal window and execute this command:
$ sudo apt update
When that's done, we can install Git with this command:
$ sudo apt install git
To confirm that you have successfully installed Git, run this command:
$ git --version
This will output the version of Git currently installed on your machine:
Output
 
git version 2.7.4
In the next section, we'll get Git configured with your username and email settings.
Configure Git Username & Email
Since Git is intended to store code on a server where multiple developers can work on it simultaneously, it's important to let Git know who you are so it can track the changes made by you.
Once you have Git installed, you can set your e-mail address and username. This information will be saved in the Git configuration at the machine level and will also be used for each of the repositories you create locally.
To set your username and e-mail, open a terminal window and execute the two following commands (replace the highlighted text with your username or e-mail):
$ git config --global user.name "Bob Dole"
$ git config --global user.email "bobdole@test.com"
Your Git username and e-mail are now set!
You can verify this information by using this command:
$ git config --list
This will list all the configuration details that have been set for Git and will output something similar:
Output
 
user.name=Bob Dole
user.email=bobdole@test.com
All of your Git settings can also be found and updated in your .gitconfig file.
Conclusion
In this article, we showed you how to install Git on Debian 9 and configure it with your username and email settings.
Check out our Introduction to Git article if you want to learn more about the version control software.
Thanks for reading and happy coding!