How to Install Git on Debian 13

Git is the world’s most popular distributed version control system used by many open-source and commercial projects. It allows you to collaborate on projects with fellow developers, keep track of your code changes, revert to previous stages, create branches , and more.
This guide covers installing and configuring Git on Debian 13 (Trixie) using apt or by compiling from source.
Quick Reference
For a printable quick reference, see the Git cheatsheet .
| Task | Command |
|---|---|
| Install Git (apt) | sudo apt install git |
| Check Git version | git --version |
| Set username | git config --global user.name "Your Name" |
| Set email | git config --global user.email "you@example.com" |
| View config | git config --list |
Installing Git with Apt
This is the quickest way to install Git on Debian.
Check if Git is already installed:
git --versionIf Git is not installed, you will see a “command not found” message. Otherwise, it shows the installed version.
Use the apt
package manager to install Git:
sudo apt update
sudo apt install gitVerify the installation:
git --versionDebian 13 stable currently provides Git 2.47.3:
git version 2.47.3You can now start configuring Git.
When a new version of Git is released, you can update using sudo apt update && sudo apt upgrade.
Installing Git from Source
The main benefit of installing Git from source is that you can compile any version you want. However, you cannot maintain your installation through the apt package manager.
Install the build dependencies:
sudo apt update
sudo apt install libcurl4-gnutls-dev libexpat1-dev cmake gettext libz-dev libssl-dev gcc wgetVisit the Git download page to find the latest version.
At the time of writing, the latest stable Git version is 2.53.0.
If you need a different version, visit the Git archive to find available releases.
Download and extract
the source to /usr/src:
wget -c https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.53.0.tar.gz -O - | sudo tar -xz -C /usr/srcNavigate to the source directory and compile:
cd /usr/src/git-*
sudo make prefix=/usr/local all
sudo make prefix=/usr/local installThe compilation may take some time depending on your system.
If your shell still resolves /usr/bin/git after installation, open a new terminal or verify your PATH and binary location with:
which git
echo $PATHVerify the installation:
git --versiongit version 2.53.0To upgrade to a newer version later, repeat the same process with the new version number.
Configuring Git
After installing Git, configure your username and email address. Git associates your identity with every commit you make.
Set your global commit name and email:
git config --global user.name "Your Name"
git config --global user.email "youremail@yourdomain.com"Verify the configuration:
git config --listuser.name=Your Name
user.email=youremail@yourdomain.comThe configuration is stored in ~/.gitconfig:
[user]
name = Your Name
email = youremail@yourdomain.comYou can edit the configuration using the git config command or by editing ~/.gitconfig directly.
For a deeper walkthrough, see How to Configure Git Username and Email .
Troubleshooting
E: Unable to locate package git
Run sudo apt update first and verify you are on Debian 13 repositories. If sources were recently changed, refresh package metadata again.
git --version still shows an older version after source install
Your shell may still resolve /usr/bin/git before /usr/local/bin/git. Check with which git and adjust PATH order if needed.
Build fails with missing headers or libraries
One or more dependencies are missing. Re-run the dependency install command and then compile again.
make succeeds but git command is not found
Confirm install step ran successfully: sudo make prefix=/usr/local install. Then check /usr/local/bin/git exists.
FAQ
Should you use apt or source on Debian 13?
For most systems, use apt because updates are integrated with Debian security and package management. Build from source only when you need a newer Git release than the repository version.
Does compiling from source replace the apt package automatically?
No. Source builds under /usr/local and can coexist with the apt package in /usr/bin. Your PATH order determines which binary runs by default.
How can you remove a source-installed Git version?
If you built from the source tree, run sudo make prefix=/usr/local uninstall from that same source directory.
Conclusion
We covered two ways to install Git on Debian 13: using apt, which provides Git 2.47.3, or compiling from source for the latest version. The default repository version is sufficient for most use cases.
For more information, see the Pro Git book .
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page