How to install latest git on Debian 8?

As of December 2015, Debian stretch/sid has git version 2.6.4. If you don't want to upgrade your entire distribution, you can look into apt pinning to bring in only git and any necessary dependencies from stretch/sid. However, many Debian folks will tell you this sort of thing is a bad idea, so building from source or waiting/asking for a backport are the only officially recommended approaches.


Backporting git from Debian testing, unstable, or experimental is fairly trivial. See How can I install more recent versions of software than what Debian provides?. Something as simple as apt-get source -t unstable git, followed up debuild -uc -us inside the source directory should work. Note that these two commands should be run as user, not root.

You might have to install some build dependencies, though. apt-get build-dep git will probably work in that case. Note that this command is run as root, not user.

Please comment if you are trying to do this and need more details.


This worked on a Debian docker container(php:5-apache).

NOTE: This currently(Mar 2018) doesn't work with an error of libc6-dev dependencies.

 RUN echo "deb http://ftp.us.debian.org/debian testing main contrib non-free" >> /etc/apt/sources.list \
         &&      apt-get update              \
         &&      apt-get install -y git      \
         &&      apt-get clean all

Tags:

Git

Debian