;

How to install Git on Debian 10

Try it in our public cloud & Get $5 Credit
CLAIM NOW
How to install Git on Debian 10.

Version control systems are also known as revision control is a component of software configuration management that helps developers manage changes to source code over time. It keeps track of every modification to the code in a special kind of database so that you can recall specific versions later. It allows you to revert selected files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more. Learn how to install Git on Debian 10.

Git is a free, open-source and distributed version control system developed by Linus Torvalds.

It is designed to handle small to large projects easily with speed. It is mainly used for source code management and helps to share and collaborate on software development projects.

Git Features

Distributed System : Git is a distributed system that means it allows users to perform work on a project from all over the world. It also allows the developers to work simultaneously on the same project, without interfering with others’ work.

Compatibility : Git is a cross-platform that means it is compatible with all the Operating Systems. It allows to access the repositories of other Version Control Systems like SVN.

Branching : It allows the users to make changes in the project without affecting the original version. The master branch is the main branch that holds the production quality code.

Open-Source : Git is an open-source that means you can modify its source code according to your needs.

Lightweight : While you clone the data Git stores all the data from the central repository on to the local repository. Git follows the criteria of lossless compression that compresses the data and stores it in the local repository. This will occupy very minimal space and saves a lot of memory space.

Speed : Compared to other version control systems Git is very fast. It is about 10 times faster than other VCS tools. It is very easy to fetch data from the local repository instead of doing the same from the remote repository.

In this tutorial, we will explain how to install Git from the Debian default repository and install it from the source on Debian 10.

Requirements

  • A server running Debian 10
  • ROOT access to the server

Getting Started

Before starting, it is always a good idea to update your system packages to the latest version. You can update all of them with the following command:

apt-get update -y
apt-get upgrade -y

Once all the packages are updated, restart your system if required by the changes.

Method 1 – Install Git From Repository on Debian 10

The simple and easiest way to install Git is to install it from Debian’s default repository. However, the version you install using the repository may be older than the newest version currently available.

You can install the Git by just running the following command:

apt-get install git -y

Once the installation is completed, you can verify the installed version of Git using the following command:

git --version

You should see the Git version in the following output:

 git version 2.20.1

If you want to remove the Git from your system, run the following command:

apt-get remove git -y

Method 2 – Install Git from Source

If you want to install the latest version of Git then you will need to compile the Git from the source. This is a very flexible method and allows you to download the latest release and will give you some control to customize it.

Before starting, you will need to install some dependencies required to compile Git in your system. You can install all of them by running the following command:

apt-get install make libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip -y

After installing all the required dependencies, visit the Git mirror using the URL https://github.com/git/git. You should see the following page:

Git source code mirror home page.

Now, click on the master branch and click on the Tags link. You should see all the version of Git in the following page:

Git source code mirror page.

Now, click on your desired Git version and click on the Clone or download button on the right side of the page then right-click on Download ZIP and copy the link address as shown below:

Select desired Git version:

Select Git version from the source code mirror.

Click on the Clone or download button on the right side of the page then right-click on Download ZIP and copy the link address.

Download Git from the source code mirror.

Now, go to your Debian 10 server, open your terminal and run the following command to download your Git version:

wget https://github.com/git/git/archive/v2.27.0.zip -O git.zip

Once the download is completed, unzip the downloaded file with the following command:

unzip git.zip

Next, change the directory to the extracted directory with the following command:

cd git-2.27.0

Then, make the package by running the following command:

make prefix=/usr/ all

Now, install the Git using the following command:

make prefix=/usr/ install

Once the installation is completed, you can verify the installed version of Git using the following command:

git --version

You should see the following output:

 git version 2.27.0

At this point, Git is installed in your system. You can now proceed to set up Git.

Setting Up Git

Next, you will need to configure Git so that the generated commit messages will contain your correct information.

You can configure the Git by specifying your name and email as shown below:

git config --global user.name "GloboTech Communications"
git config --global user.email "sysadmin@globo.tech"

After configuring Git, you can verify the configuration using the following command:

git config --list

If everything is fine you should get the following output:

user.name=GloboTech Communications
user.email=sysadmin@globo.tech

You can also edit the above information manually by editing ~/.gitconfig file:

cat ~/.gitconfig

You can see your configuration information in the following output:

[user]
      name = GloboTech Communications
      email = sysadmin@globo.tech

At this point, you have successfully compiled and set up Git from the source.

Conclusion

In the above guide, you learned how to install Git on Debian 10 from the repository and compile it from the source. I hope this will help you to install your desired version of Git. For more information about Git, visit the official Git documentation.