How to Install Git on Debian A Comprehensive Step by Step Tutorial [25 Simple Steps]

Written by

Reviewed by

Last updated: July 26, 2023

Expert verified

SVG Image


To learn to install Git on Debian, you can follow these steps:

  1. Use the command lsb_release -a to identify the specific version of Debian you are running. 
  2. Execute sudo apt update to refresh the package lists and sudo apt upgrade to install any available updates for your Debian system.
  3. Install the necessary build dependencies for Git by running sudo apt install build-essential libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip.
  4. Navigate into the extracted Git source code directory using cd git-x.x.x. Then, run ./configure to configure Git for your Debian system. Next, execute make to compile the source code into executable files. Finally, install Git with administrative privileges by running sudo make install.

When installing Git on Debian, it is common to encounter errors such as dependency conflicts, access denied, internet connection issues, and repository not found. By understanding and resolving these errors, you can overcome installation challenges and successfully set up Git for efficient version control on your Debian system.

Continue reading the guide below to learn the step-by-step process to install Git on Debian and common errors that can occur when installing and using Git on Debian.

Installing Git on Debian is the key to unlocking a world of efficient collaboration, seamless code management, and easy project tracking. Git is widely known for its stability, security, and vast package repositories. Whether you are a developer, sysadmin, or an enthusiastic learner, understanding how to install Git on Debian is essential for efficient version control and collaborative software development. In this guide, I will walk you through the step-by-step guide to Install Git on Debian and how to configure it. I will also discuss some of the common errors that can occur and how to troubleshoot them.

How to Install Git on Debian

To install Git on Debian, your system should meet the following requirements: Debian Linux (any version), a 1 GHz or faster processor, 512 MB RAM or more (1 GB recommended), at least 50 MB of free disk space, and a stable internet connection if using the package manager. Follow this step-by-step guide:

  1. Open your Terminal window.
opening terminal 15
  1. Execute the following command to determine your Debian version:
<strong>lsb_release -a</strong>
  1. The output will display your Debian version, such as Debian 11 (Bullseye). Note down the version as it will be required during the installation process.
checking debian version
  1. Run the following command to update the package lists:
<strong>sudo apt update</strong>
  1. The command will update the package lists.
updating system package list 6
  1. Run the following command to upgrade the installed packages:
<strong>sudo apt upgrade</strong>
  1. Debian will fetch and install the updated packages. If prompted, review the changes and confirm the upgrade by entering y.
upgrading system packages to the latest version 1
  1. Execute the following command to install the required build dependencies:
<strong>sudo apt install build-essential libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip</strong>
  1. This command installs necessary dependencies for building Git from source.
installing necessary dependencies 1
  1. Next, visit the Git official website and download the source code package corresponding to the desired version.
visit official website of git
  1. Choosing the latest version of the git source file from the tab.
choosing latest version for git
  1. Now click on the Code button and download the zip file.
downloading source file
  1. Once the download completes, navigate to the directory by running the command:
<strong>cd path/to/directory</strong>

Replace path/to/directory with the actual path.

navigating to directory containing downloaded file
  1.  extract the package using the following command:

Replace with the actual downloaded filename.

  1. This command extracts the downloaded Git package.
extracting file
  1. To move into the extracted directory run the command:
<strong>cd git-x.x.x</strong>

Replace git-x.x.x with the actual extracted directory name.

  1. This command changes your current working directory to the extracted Git directory.
navigating to extracted directory
  1. To configure Git for your Debian system run the command:
  1. This command configures Git specifically for your Debian system.
installing GIT on debian
  1. Now run the command:
  1. This command compiles the Git source code and builds the executable files.
building installtion environment for GIT
  1. Finally to install git on Debian enter the command:
<strong>sudo make install</strong>
  1. This command installs Git system-wide, allowing all users on your Debian system to access it.
installing GIT on debian 1
  1. After the installation process completes, verify the Git installation by running the following command:
<strong>git --version</strong>
  1. The Terminal should display the installed Git version, confirming the successful installation.
verifying installed version of GIT

How to Configure Git on Debian

Configuring Git on Debian is essential to personalize your Git experience and optimize your workflow for efficient version control. By setting up your user information, such as your name and email address, you establish your identity in Git commits. This allows for accurate tracking of contributions and collaboration. Follow these steps:

  1. Open the Terminal and enter the following commands, replacing the placeholder values with your desired username and email address:
<strong>git config --global "Your Name"</strong>
<strong>git config --global "</strong><a href=""><strong></strong></a><strong>"</strong>
  1. Your user information is now set up and associated with Git.
setting up user information in git

4 Common Errors When Installing Git on Debian

It is common to encounter errors during the installation of Git on Debian. By being aware of these common errors and their solutions, you can troubleshoot and overcome any challenges that may arise during the installation of Git on Debian. Here are four common errors that can occur:

  • 🚫 Dependency Conflict: During the installation, you might encounter a dependency conflict error. This occurs when Git requires specific versions of libraries or packages that are not met. As a result, you may receive an error message indicating missing or incompatible dependencies. To resolve this, check the version requirements of Git and ensure that the necessary dependencies are installed and up to date. Use the package manager to install any missing dependencies or update conflicting packages.
  • ⚠️ Access Denied: Sometimes, you may face access denied error during Git installation on Debian. This error typically arises when the user executing the installation command lacks the necessary permissions to access or modify certain directories or files. To resolve this, execute the installation command with administrative privileges using the sudo command. This grants the necessary permissions to access and modify system directories during installation.
  • 🔄 Internet Connection Issues: If your Debian system experiences unstable or no internet connection during Git installation, you may encounter errors related to package retrieval or download failures. This can happen when the package manager cannot connect to the repositories to fetch the required packages. To address this, ensure that your internet connection is stable and functioning properly. If you face connection issues, try troubleshooting your network or consider using an alternative mirror or repository for package retrieval.
  • Repository Not Found: At times, you may come across an error indicating that the Git package or repository cannot be found. This can occur due to misconfigured package sources or repositories, or if the package manager fails to locate the necessary packages. To resolve this, check your package sources or repositories to ensure they are correctly configured. Verify that the repositories are accessible and that the necessary sources are enabled. If the issue persists, try updating your package lists and repositories using the package manager’s update command.

To Sum Up

I hope this guide has provided you with a comprehensive step-by-step tutorial on how to install Git on Debian and configure it. By following the installation steps outlined and being aware of common errors that may occur, you can confidently set up Git on your Debian system.

To further enhance your Git skills and explore advanced topics, consider diving into the following articles: Effective Collaboration Strategies and Workflows, Git Branching and Merging, and Git Hooks to Automate Workflows and Ensuring Code Quality. Remember, Git is a versatile tool with endless possibilities. Continuously learning and exploring its features will empower you to become a proficient Git user, enhancing your development projects and productivity.

Frequently Asked Questions

Can I install multiple versions of Git on Debian?

While it is technically possible to have multiple versions of Git installed on Debian, it is generally recommended to have only one version to avoid conflicts and ensure consistent usage across projects. Managing multiple versions can be complex and lead to compatibility issues. If you need to work with different versions of Git, consider using version management tools like git-switch or containerization technologies like Docker to isolate different versions in separate environments. These tools allow you to switch between Git versions seamlessly and maintain project-specific dependencies.

How can I integrate Git with my preferred IDE or text editor on Debian?

Integrating Git with your preferred IDE or text editor on Debian can significantly improve your development workflow. Most popular IDEs and text editors like Visual Studio Code, Atom, and Sublime Text offer Git integrations through plugins or built-in features. To integrate Git, you can typically install a Git plugin or extension specific to your IDE or text editor. These plugins directly provide functionalities like version control, branch management, commit history, and conflict resolution within the IDE or text editor’s interface. Consult the documentation or extension marketplace of your IDE or text editor for specific instructions on installing and configuring Git integration.

Are there any GUI tools available for Git on Debian?

Absolutely! There are several excellent graphical user interface (GUI) tools available for Git on Debian that provide a user-friendly visual interface for managing Git repositories. Some popular GUI tools include GitKraken, SourceTree, and GitAhead. These tools offer features such as a visual representation of branch history, seamless branch creation and switching, conflict resolution, and built-in Git commands. GUI tools can be particularly helpful for newcomers to Git or those who prefer a more visual approach to version control. To install these GUI tools, you can download them directly from their respective websites and follow the installation instructions provided.

How can I recover a lost Git commit or discarded changes on Debian?

If you accidentally delete a commit or discard changes in Git on Debian, there are ways to recover them. First, you can use the git reflog command, which lists the commit history, including the commits that may have been removed or lost. You can find the commit reference in the reflog and use it to restore the lost commit. Additionally, Git provides the git stash command, allowing you to temporarily save changes that were not committed before switching branches or performing other operations. You can later retrieve these changes using the git stash apply command. These Git features offer flexibility in recovering lost commits or changes in your development process.



Ojash is a skilled Linux expert and tech writer with over a decade of experience. He has extensive knowledge of Linux's file system, command-line interface, and software installations. Ojash is also an expert in shell scripting and automation, with experience in Bash, Python, and Perl. He has published numerous articles on Linux in various online publications, making him a valuable resource for both seasoned Linux users and beginners. Ojash is also an active member of the Linux community and participates in Linux forums.



Akshat is a software engineer, product designer and the co-founder of Scrutify. He's an experienced Linux professional and the senior editor of this blog. He is also an open-source contributor to many projects on Github and has written several technical guides on Linux. Apart from that, he’s also actively sharing his ideas and tutorials on Medium and Attirer. As the editor of this blog, Akshat brings his wealth of knowledge and experience to provide readers with valuable insights and advice on a wide range of Linux-related topics.

Share this article
Shareable URL
Prev Post

How to Install ClamAV on Ubuntu and Configure It [12 Easy Steps]

Next Post

How To Add and Delete Users on Debian [ 6 Easy Methods ]

Leave a Reply

Your email address will not be published. Required fields are marked *

Read next