Git from src on Debian
Posted on 08 August 2025
1 minute read
Most linux distros have git packages available, but many are not the latest version. Due to this, and the fact the ones on Debian are often quite far behind, I like to build git from src. You can use the following steps to do this. We'll need some build dependencies so we'll also update our packages first.
sudo apt update
sudo apt install gettext libcurl4-gnutls-dev libexpat1-dev libghc-zlib-dev libssl-dev make
Now that we have our build dependecies installed, let's go ahead and grab the git tarball from the tags page. At the time of publishing this post, the stable version was 2.50.1. The easiest way to grab this is with curl
:
cd /tmp
curl -OL https://github.com/git/git/archive/refs/tags/v2.50.1.tar.gz
Now unpack the tarball
tar zxvf v2.50.1.tar.gz
Now we can build git (this will likely take a few minutes!)
cd git-2.50.1
make prefix=/usr/local all
Once the make process has completed, we can go ahead and install it
sudo make prefix=/usr/local install
Once installed, you can test the version to confirm everything went according to plan
git --version
git version 2.50.1
Congratulations! You have now successfully built git from source.
To clean up, you can also remove the source files
rm -rf /tmp/git-*
rm /tmp/v2.50.1.tar.gz