git: command not found means Git is not installed — it is not part of a base server or container image. One package fixes it on every distribution; the only nuance is picking the right package manager.
Install Git
sudo apt update
sudo apt install -y gitsudo dnf install -y gitapk add --no-cache gitsudo pacman -S --noconfirm git # Arch
sudo zypper install -y git # openSUSEVerify and set your identity
Confirm the install, then set the name and email every commit is stamped with — skip this and your first git commit will complain:
git --version
git config --global user.name "Your Name"
git config --global user.email "[email protected]"In a Dockerfile
Installing Git into an image is the same idea, with the cache cleaned in the same layer to keep the image small:
RUN apt-get update && apt-get install -y git \
&& rm -rf /var/lib/apt/lists/*Installed but still not found
If the package is present but the shell disagrees, it cached an old lookup or PATH is stripped:
hash -r
command -v git || ls -l /usr/bin/git
echo $PATHCloning a large repository is I/O-bound, so it benefits from fast storage. Every VMHeaven KVM plan runs on NVMe-backed enterprise storage, which keeps clones and builds quick.
Frequently asked
Do I need anything besides the git package?
Just set your identity: git config --global user.name and user.email. Without them your first commit will refuse to run.
Should Git be installed on a production server?
Not necessarily. Building in CI and copying the artefact over is cleaner than cloning a repository onto the live host.
Git is installed but still not found — why?
The shell cached an old lookup or PATH is stripped. Run 'hash -r' and check 'command -v git' and $PATH.