5

I want to install Git on Debian 9. I ran apt install git-all as it says on Git site but it installed version 2.11.0.

I thought that there was a need for packages update, but apt-get update and apt-get upgrade didn't change anything. It appears that this Git version is the latest stable for Debian 9.

I want to use a more recent Git version. What is the best I can do?

4
  • 3
    This question belongs on superuser.com, but the short answer is: point your system at a later set of packages. The official release for your system is Git 2.11.0. Adding other repositories (these aren't Git repositories, they're Debian package repositories) will let you use a later-than-official-release version that someone has provided.
    – torek
    Nov 9, 2021 at 10:08
  • Debian 9 is way past its useful life for modern development. There is nothing to prevent you from compiling a new version of Git (or finding someone who has already done that) but the absolutely simplest solution is to use a version of Debian which actually receives updates. Even then, your expectations are probably not going to be fulfilled (the current version of Debian, version 11 aka "Bullseye", ships Git 2.30.2 -- package version 1:2.30.2-1 -- whereas upstream is up to 2.33.1 which will only be available in the next version of Debian, if even then).
    – tripleee
    Nov 9, 2021 at 11:19
  • packages.debian.org/… has backported 2.30 packages for Buster (Debian 10); more generally, try backports.debian.org/Packages but currently that's the only hit for git.
    – tripleee
    Nov 9, 2021 at 11:21
  • Thank you for your answers, every answer contain useful info. I am a new Debian user, so all this info is helpful. What I end up doing, was to follow the instructions and install Git from source. Now the git --version replies with 2.33.1 I will post the answer. Nov 9, 2021 at 12:29

2 Answers 2

9

Maybe a backports version for the Debian release you are using provides a more recent git version which satisfies your requirements.

Taking the Debian 11 (bullseye) release as an example, bullseye's default git package is on version 2.30.x, whereas bullseye-backport's git is on version 2.34.x. This more recent git version is especially desirable as it allows to sign commits with SSH keys.

First you need to add the bullseye-backports package source to your bullseye system (I don't know if e.g. the older stretch would allow to use bullseye-backports), then after an apt update, you will be able to install the backports git package:

echo "deb http://deb.debian.org/debian bullseye-backports main" >/etc/apt/sources.list.d/bullseye-backports.list

apt update
apt install git/bullseye-backports
1
  • 1
    I had come across this solution when I was looking into it, but I try to avoid backports because their packages are a bit less tested. The main reason I use Debian is because of their stability. But in this case, since we are talking about git I don't think there would be a problem. Thank you. Nov 23, 2022 at 9:26
3

In order to run the latest Git version, I followed the instructions on Installing from Source on the official Git site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.