Git is a distributed version control system that helps developers track changes to source code over time. It enables coordination between multiple developers working on the same codebase. Installing the latest version of Git on Debian 11 is important to take advantage of new features and security fixes. Here is a step-by-step guide on how to install Git on Debian 11 Bullseye.

Prerequisites

Before installing Git, ensure your system is up-to-date by running:

sudo apt update
sudo apt upgrade -y

Some compiler tools and libraries are also required. Install them with:

sudo apt install build-essential libcurl4-gnutls-dev libexpat1-dev \
gettext libz-dev libssl-dev -y

Download the Latest Git Release

Next, navigate to the Git releases page and find the latest version:

cd /tmp
curl -LO https://www.kernel.org/pub/software/scm/git/git-$(curl -s https://www.kernel.org/pub/software/scm/git/ | grep -Po ‘git-\K[\d.]+‘ | head -1).tar.xz

This will download the latest Git release into /tmp.

Extract and Compile Git

Extract the archived Git release with:

 
tar -xf git-*.tar.xz
cd git-*

Then compile Git with:

make prefix=/usr/local all
sudo make prefix=/usr/local install

This builds Git and installs it into /usr/local.

Configure Environment Variables

So Git can be easily used system-wide, some environment variables need to be set.

Add the following to your shell profile (e.g. ~/.bashrc for Bash):

export PATH=/usr/local/bin:$PATH 
export LD_LIBRARY_PATH=/usr/local/lib

Then reload it with:

source ~/.bashrc

Verify the Git Installation

Check Git is installed properly with:

git --version

It should print the latest Git version.

You can now start using Git! Initialize a repository, make commits, push/pull from remotes and manage branches.

Conclusion

Installing the latest Git version on Debian 11 ensures access to the most recent features and security updates. By compiling from source, you aren‘t limited to only the version in Debian‘s repositories. Now developers can efficiently collaborate with the best Git tooling available.

Similar Posts