This tutorial will show you how to install and configure Git on Debian 9.

Git is the world’s most popular distributed version control system used by many open source and commercial projects. It allows you to keep track of your code changes, revert to previous stages, create branches and to collaborate with your fellow developers.

Git is originally developed by Linus Torvalds, the creator of the Linux kernel.

This tutorial was tested on Debian 9 but it should also work with any previous Debian version.

Prerequisites

Installing Git with Apt

The easiest and the recommended way to install Git is by using the apt package management tool from the Debian’s default repositories. If you want to install the latest stable version of Git move on to the Installing Git from Source section of this tutorial.

The following steps will show you how to install Git on your Debian system:

Update package index.

Before installing new packages you should always update the apt package index:

sudo apt update

Install Git.

Once the list is updated issue the following command to install Git:

sudo apt install git

Verify Git installation.

To verify the installation type the following command to print the Git version:

git --version

git version 2.11.0

As you can see from the output above, you have successfully installed Git version 2.11.0. You can now move on to the Configuring Git section of this tutorial to complete your setup.

Advertisement

Installing Git from Source

Another installation option is to compile Git from source which will allow you to install the latest Git version and to customize the build options, but you will not be able to maintain your Git installation through the apt package manager.

Before continuing with the next steps, first you need to install the packages necessary to build Git on your Debian system: