Install more recent (or latest) Git version in Debian 9
Asked Answered
F

2

8

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?

Faceplate answered 9/11, 2021 at 10:5 Comment(4)
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.Leopoldeen
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).Stadia
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.Stadia
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.Faceplate
F
3

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

Faceplate answered 9/11, 2021 at 17:13 Comment(0)
D
13

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
Directory answered 22/11, 2022 at 7:36 Comment(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.Faceplate
F
3

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

Faceplate answered 9/11, 2021 at 17:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.