Git is the distributed version control system behind the Linux kernel, most open-source projects, and everyday git clone / git push workflows. Debian includes Git in its main archive, so a normal desktop or server can install the CLI with one apt command and receive security fixes through the same upgrade path as the rest of the system.
This guide covers install Git on Debian for Debian 11 (Bullseye), 12 (Bookworm), and 13 (Trixie): install with apt, optionally pull a newer packaged build from backports, build upstream Git from the official kernel.org source directory, configure your identity, run a first commit, update, and uninstall. I ran these steps on Debian 13 and kept real terminal output below.
Tested on: Debian 13 (trixie); kernel 6.12.94+deb13-amd64; amd64; Git 2.47.3 via apt; Git 2.54.0 via source build under
/opt/git-2.54.0.
Choose an install method
| Method | Best for | Updates |
|---|---|---|
apt install git |
Servers, desktops, CI runners (recommended) | sudo apt upgrade or sudo apt install --only-upgrade git |
| Backports | Older stable releases when a newer packaged Git exists | Same apt workflow against the backports suite |
| Source tarball (kernel.org) | Workstations that need the current upstream tag | Manual rebuild when you choose |
Most readers should use apt. Debian maintains the package, dependencies, and security support. Keep the Pro Git — Installing Git source instructions for the rare case where upstream moves ahead of your release.
Check your current Git
Before installing, see whether Git is already present and which package Debian offers:
. /etc/os-release && echo "$PRETTY_NAME"
git --version 2>/dev/null || echo "git: not installed"
command -v git 2>/dev/null || true
apt-cache policy gitOn Debian 13 with Git already installed:
Debian GNU/Linux 13 (trixie)
git version 2.47.3
/usr/bin/git
git:
Installed: 1:2.47.3-0+deb13u1
Candidate: 1:2.47.3-0+deb13u1Typical default versions by release (check packages.debian.org/git for the current revision):
| Debian release | Upstream version (git --version) |
|---|---|
| Debian 13 (trixie) | 2.47.x |
| Debian 12 (bookworm) | 2.39.x |
| Debian 11 (bullseye) | 2.30.x |
Upstream stable at the time of writing is 2.54.0 (git-scm.com). That gap is normal on stable distributions—only switch to backports or source when your project actually needs a newer Git.
Install Git with apt (recommended)
The Git project’s Linux install page documents Debian/Ubuntu installation as:
sudo apt update
sudo apt install -y gitOn my host apt install reported:
Setting up git (1:2.47.3-0+deb13u1) ...
Processing triggers for man-db (2.13.1-1) ...Verify the binary and package:
git --version
which git
dpkg -l gitgit version 2.47.3
/usr/bin/git
ii git 1:2.47.3-0+deb13u1 amd64 fast, scalable, distributed revision control systemapt installs the core client plus dependencies such as git-man. Optional GUI and integration packages (git-gui, gitk, git-email) are separate—install them when you need them, or use the git-all metapackage if you want the full set from packages.debian.org.
Prerequisites: sudo and working apt sources (deb.debian.org or your mirror).
Install a newer Git from backports (optional)
On an older stable release, Debian Backports sometimes ships a newer git package before the next Debian release. Follow Debian Backports — Instructions and the Debian Wiki — Backports.
Example for bookworm (adjust the suite name for your release):
echo 'deb http://deb.debian.org/debian bookworm-backports main' | \
sudo tee /etc/apt/sources.list.d/bookworm-backports.list
sudo apt update
apt-cache policy gitIf a backports candidate appears, install it explicitly:
sudo apt install -y git/bookworm-backports
git --versionSearch backports.debian.org before enabling backports—not every release backports Git. When no backports entry exists, use the source method below or stay on the default apt package.
Build Git from the official source tarball
Use this when you need the current upstream release and Debian’s package (and backports, if any) is too old. The Pro Git book lists the build dependencies for Debian-based systems:
sudo apt install -y build-essential libcurl4-gnutls-dev libexpat1-dev \
gettext libssl-dev zlib1g-dev ca-certificates curl xz-utilsCreate a build directory and download the latest stable tarball from kernel.org:
mkdir -p ~/git-build && cd ~/git-build
GIT_VERSION=2.54.0
curl -fLO "https://www.kernel.org/pub/software/scm/git/git-${GIT_VERSION}.tar.xz"
tar -xf "git-${GIT_VERSION}.tar.xz"
cd "git-${GIT_VERSION}"Compile and install under a versioned prefix (keeps files separate from Debian’s apt package):
make -j"$(nproc)" prefix="/opt/git-${GIT_VERSION}" all
sudo make prefix="/opt/git-${GIT_VERSION}" install
sudo ln -sfn "/opt/git-${GIT_VERSION}/bin/git" /usr/local/bin/git
hash -rOn my VM the compile step took several minutes. Near the end of make install:
install -d -m 755 '/opt/git-2.54.0/bin'
install -m 755 git '/opt/git-2.54.0/bin/git'Verify which binary your shell uses:
command -v git
readlink -f "$(command -v git)"
git --version
/usr/bin/git --version/usr/local/bin/git
/opt/git-2.54.0/bin/git
git version 2.54.0
git version 2.47.3/usr/local/bin normally precedes /usr/bin on Debian, so git runs the source build while the apt package remains at /usr/bin/git for rollback.
apt git package just to “avoid confusion” unless you manage updates yourself. Keeping both lets you switch back by removing the /usr/local/bin/git symlink.
Release tarballs and tags are also listed on the official Git repository on GitHub; kernel.org is the canonical download location cited in the Pro Git book.
Configure Git on Debian
Git runs without global configuration, but commits require user.name and user.email. Set them once per account (see git config global for more options):
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --global init.defaultBranch mainConfirm:
git config --global --get user.name
git config --global --get user.email
git config --global --get init.defaultBranchYour Name
[email protected]
mainSettings live in ~/.gitconfig. Omit --global inside a single repository when that project needs a different identity.
Create a test repository
After install and configuration, confirm Git can initialize, stage, and commit:
mkdir -p /tmp/git-debian-test && cd /tmp/git-debian-test
git init -b main
printf 'hello\n' > README.md
git add README.md
git commit -m "Initial commit"
git status
git log --oneline -1Initialized empty Git repository in /tmp/git-debian-test/.git/
[main (root-commit) ea4fca2] Initial commit
1 file changed, 1 insertion(+)
create mode 100644 README.md
On branch main
nothing to commit, working tree clean
ea4fca2 Initial commitFor day-to-day commands after this smoke test, see the git init tutorial. Python workflows that clone from GitHub also assume a working git binary—see install Python package from GitHub.
Update Git
Apt-installed Git updates with the rest of the system:
sudo apt update
sudo apt upgradeUpgrade only Git when a new Debian revision is available:
sudo apt update
sudo apt install --only-upgrade gitSource-built Git does not update through apt. Download a newer tarball from kernel.org, rebuild under /opt/git-NEWVERSION, and move the /usr/local/bin/git symlink. Remove old /opt/git-* directories when you no longer need them for rollback.
Uninstall Git
Match removal to how you installed.
Remove the apt package:
sudo apt remove git
sudo apt autoremove
dpkg -l git | grep '^ii' || echo 'apt git package is not installed'Remove a source build (only when /usr/local/bin/git points into /opt/git-*):
readlink -f /usr/local/bin/gitIf the path is under /opt/git-2.54.0 (replace with your version):
sudo rm -f /usr/local/bin/git
sudo rm -rf /opt/git-2.54.0
hash -r
command -v git || git --versionAfter removing the symlink, git resolves to /usr/bin/git again if the apt package is still installed.
User-level files (~/.gitconfig, ~/.git-credentials) are not removed by apt remove. Delete them only when you no longer need that identity or cached credentials.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
git: command not found |
Package not installed or symlink missing | sudo apt install git or recreate the /usr/local/bin/git symlink for source builds |
fatal: unable to access 'https://…': SSL certificate problem |
Stale or missing CA bundle | sudo apt install --reinstall ca-certificates |
Please tell me who you are on commit |
Missing user.name / user.email |
Run the git config --global commands in the configuration section |
[email protected]: Permission denied (publickey) |
SSH key not on the hosting account | See fatal: Could not read from remote repository |
git --version still shows the apt release after source install |
PATH prefers /usr/bin |
hash -r; confirm command -v git is /usr/local/bin/git |
References
- Git — Install for Linux
- Pro Git — Installing Git
- packages.debian.org — git
- Debian Wiki — Backports
- Debian Backports — Instructions
- kernel.org — Git source releases
- github.com/git/git — official repository
- On-site: git init tutorial, git config global, apt command, install Python package from GitHub
Summary
Install Git on Debian with sudo apt update && sudo apt install -y git for almost every server and workstation—Debian’s package is maintained, integrates with ca-certificates and OpenSSH, and updates through normal apt upgrades. When an older stable release needs a newer packaged Git, enable backports and install git/RELEASE-backports if backports.debian.org lists one. Build from the kernel.org tarball only when you need the current upstream tag; install under /opt/git-VERSION and symlink /usr/local/bin/git so the apt copy stays available at /usr/bin/git. Set user.name, user.email, and init.defaultBranch before your first real commit.

