How to Install Git on Debian/Ubuntu/Arch/Void/NixOs/Generic Linux Distros

How to Install Git on Debian/Ubuntu/Arch/Void/NixOs/Generic Linux Distros

Easierdocs Git Install Article Image

Debian/Ubuntu

Using apt package manager:

sudo apt update
sudo apt install git

Fedora/CentOS/RHEL

Using dnf or yum:

# For Fedora and newer CentOS/RHEL
sudo dnf install git

# For older CentOS/RHEL
sudo yum install git

Arch Linux

sudo pacman -Sy git

NixOs

nix-shell -p git

or system wide with,

/etc/nixos/configuration.nix
environment.systemPackages = [
    pkgs.git
];

Void Linux

sudo xbps-install -S git

openSUSE

sudo zypper install git

Generic 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-dev

Step 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 install

Step 4 - Verify the installation

git --version

If this outputs the current version, the installation was successful.

Last updated on