How to Install Git on Debian/Ubuntu/Arch/Void/NixOs/Generic Linux Distros
Debian/Ubuntu
Using apt package manager:
sudo apt update
sudo apt install gitFedora/CentOS/RHEL
Using dnf or yum:
# For Fedora and newer CentOS/RHEL
sudo dnf install git
# For older CentOS/RHEL
sudo yum install gitArch Linux
sudo pacman -Sy gitNixOs
nix-shell -p gitor system wide with,
/etc/nixos/configuration.nix
environment.systemPackages = [
pkgs.git
];Void Linux
sudo xbps-install -S gitopenSUSE
sudo zypper install gitGeneric Linux Distros
Step 1 - Install dependencies
First, install the required dependencies for building Git from source:
sudo apt update
sudo apt install dh-autoreconf libcurl4-openssl-dev libexpat1-dev libssl-dev zlib1g-dev libz-devStep 2 - Download Git source code
Download the latest version of Git from the official website or use wget:
wget https://github.com/git/git/archive/refs/tags/v2.45.2.tar.gzℹ️
You can check for the latest version on the Git releases page.
Step 3 - Extract and compile
tar -zxf v2.45.2.tar.gz
cd git-2.45.2
make configure
./configure --prefix=/usr/local
make all
sudo make installStep 4 - Verify the installation
git --versionIf this outputs the current version, the installation was successful.
Last updated on