Sep 1, 2023 4 min read

How to Install Git on Debian 11

Install Git on Debian 11 with our step-by-step tutorial. Git is a popular open-source distributed version control system.

Install Git on Debian 11
Table of Contents

Choose a different version or distribution

Introduction

Before we go into how to install Git on Debian 11, it's important to first understand - what is Git?

Git is a popular open-source distributed version control system that can handle a wide range of projects, from small to large, quickly and efficiently. It stands out since it is user-friendly and simple to understand.

Git enables parallel development and easy integration of code changes. Git also provides a complete version history, allowing developers to revert changes if needed. It's a powerful tool embraced by the software development industry, offering speed, performance, and a robust platform for streamlined collaboration.

In this tutorial, you will install Git on Debian 11. Installing Git can be done in two ways. You can use the APT package manager to install from Debian repositories, or you can install directly from the source, which will give you the most recent version of Git.

Advantages of Git

  1. Distributed Version Control: Git allows for collaboration on projects by enabling multiple developers to work on the same codebase simultaneously, making it easy to merge changes.
  2. Speed and Performance: Git's architecture ensures fast operations, as the codebase is stored locally, minimizing network delays.
  3. Branching and Merging: Git's branching model allows for creating and managing isolated code branches, facilitating parallel development and seamless merge operations.
  4. Version History and Undoing Changes: Git tracks every change made to a project, providing a complete version history and effortless reverting of changes.
  5. Wide Industry Adoption and Support: Git is widely used in the software development industry, with a large community, extensive documentation, and continuous updates, making it reliable and well-supported.

Method 1: Install Git Using APT package Manager

To begin, make sure Debian's package index is up to date.

sudo apt update

Once the update is complete, use the simple command supplied to install Git from Debian's APT repository.

sudo apt install git

Check the version of Git after it's been installed:

git --version

Method 2: Installing Git from Source

Installing Git from the source is a better and more flexible solution. While this is a lengthier process, it will ensure that you have the most recent version of Git.

Install all of the Git dependencies first:

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

After you've finished installing Git, go to the project's Github page.

https://github.com/git/git

Navigate to the 'Master' branch, click the 'Tags' link, and select the most recent Git option, which is usually the top choice. Selecting the release candidate version is not recommended (which bears the suffix rc). This is a Beta version, so expect it to be buggy and unstable.

Git version 2.34.1 is the most recent version at the time of authoring this tutorial. This is the version that we'll be installing.

Select the latest Git version

Click the 'Code' button on the far right, then copy the 'Download ZIP' option link.

Clone git repository on Github

Return to your Debian 11 server and use the wget command to get the zip file.

wget  https://github.com/git/git/archive/refs/heads/master.zip -O git.zip

After that, unzip the compressed file.

unzip git.zip

Then go to the directory that isn't compressed.

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

Verify that you have the most recent version of Git when the installation is complete.

git --version

How to Set Up Git

We've successfully installed Git on Debian 11 Server at this stage. There's just one last thing to do. We'll need to configure it so that commit messages contain the relevant information.

We'll give our name and email address, which will be included in the commit messages. To do so, use the git config commands listed below.

git config --global user.name "Vega"
git config --global user.email "[email protected]"

Run the following command to verify that the configuration has been set up:

git config --list

The /.gitconfig file contains these details. You can also double-check by looking at the file.

cat ~/.gitconfig

FAQs to Install Git on Debian 11

Can I install a specific version of Git on Debian 11? 

Debian's package repositories offer the latest stable versions. If you need a specific version, consider adding additional repositories or manually installing from source.

How do I update Git to the latest version on Debian 11? 

To update Git, open the terminal and execute: sudo apt update && sudo apt upgrade git. This command will update Git if a newer version is available.

Does installing Git on Debian 11 require a system reboot? 

No, installing Git doesn't require a system reboot. Once the installation is complete, you can start using Git immediately.

Are there any additional packages that get installed with Git on Debian 11?

When you install Git on Debian 11, its dependencies such as git-man and liberror-perl are automatically installed to ensure complete functionality.

How can I uninstall Git from Debian 11? 

Open the terminal and run: sudo apt remove git to uninstall Git from your Debian 11 system. This command will remove Git and its associated dependencies.

Will uninstalling Git remove my existing repositories and configuration files? 

Uninstalling Git won't remove your repositories or configuration files. They are independent of the Git package and will remain intact.

Is it possible to install Git from source on Debian 11?

Yes, you can install Git from source. Download the source code from the Git website, follow the instructions in the documentation, and compile it on your Debian 11 system.

Conclusion

You may now use Git to host your work on Github or any other code hosting and collaboration platform. We led you through the installation of Git on a Debian 11 server in this tutorial.

Leave a comment below if you run into any issues or have any feedback.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.