Install Git on Debian 9 System - Step by Step Process ?

Git is the most popular Software version control system used to track changes in source code during software development. Also, It allows programmers to collaborate, revert to previous changes and create branches.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Git queries on any Linux Distribution.

In this context, we shall look into how to install Git on Debian system.

Different methods of Installing Git on Debian 

Before performing this installation procedure, ensure that you are using a user with sudo privileges.

To install Git on Debian, we can use any of the given methods:

  • Installing Git on Debian with Apt.
  • Installing Git from a Source.

1. Install Git on Debian with Apt

Git is available at Debian default apt repository so we will install from there. It’s always recommended to install packages from Debian default repository.

i. So first of all we need to update apt package manager index using below command:

$ sudo apt update

ii. Once the list is updated execute the below command to install Git:

$ sudo apt install git

iii. You can verify the installation by typing:

$ git --version

It will show output like below:

git version 2.11.0

That's all. You have successfully installed Git version on you Debian system.

2. Installing Git from a Source

Another installation method is to compile the software from source. It will allow you to download the latest release and to do customization. But you can't manage Git package from apt package manager.

i. Before you start, you need to install necessary software which Git required. These all are available from default Debian repository. Execute below commands:

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

ii. After that, you can go ahead and get the version of Git you want by visiting the Git project's mirror on GitHub and copy the latest release link address that ends in .zip

iii. Now we will download Git source to /tmp directory on your Debian system. Move to /tmp directory by typing:

$ cd /tmp

iv. Use the wget command to download the archive file as

$ sudo wget -O

v. Once download is finished, unzip the downloaded file and move to the git source directory by typing:

$ unzip
$ cd git-*

vi. Now, you can compile and install Git by typing these two commands:

$ sudo make prefix=/usr/local all
$ sudo make prefix=/usr/local install

vii. Again, you can verify installation by typing:

$ git --version

It should show installed version of Git as given below:

git version 2.21.0

Later, if you have need to upgrade to a newer version, you can repeat the installation process.

How to Set up Up Git ?

Now your Git is installed and you need to configure it by setting up email address and username:

$ git config --global "Admin"
$ git config --global ""

You can see entered details by typing:

$ git config --list

Output Name
These settings are stored at ~/.gitconfig file and you can see content as below:
   name = Admin
   email =

You can make other git configuration changes by using git config command or you can edit the ~/.gitconfig file manually.

How to Uninstall Git from Debian Linux System ?

To remove just git package itself from your system, execute the command below on terminal:

$ sudo apt-get remove git

To remove the git package and any other dependent package which are no longer needed from system Trusty, run the following command:

$ sudo apt-get remove --auto-remove git

If you also want to delete configuration and/or data files of git from Ubuntu Trusty then this will work, run the command:

$ sudo apt-get purge git

To delete configuration and/or data files of git and it's dependencies from Ubuntu Trusty then execute:

$ sudo apt-get purge --auto-remove git

[Need help in fixing Debian Software Packages Installation ? We can help you. ]

This article covers how to install Git on your Debian server and how to Setting up Git. With versioning tools such as Git, you can track changes, revert to previous stages, and branch to create alternate versions of files and directories.

How to Install Git with Default Packages on Debian?

1. First, use the apt package management tools to update your local package index. 

After updating the system, you can download and install Git:

$ sudo apt update
$ sudo apt install git

2. You can confirm that you have installed Git correctly by running the following command:

git --version

Related Posts