Most Ubuntu development workflows expect Git before you clone a repository, fetch source code, or push work to GitHub, GitLab, or Bitbucket. You can install Git on Ubuntu 26.04, 24.04, and 22.04 with APT, move to the Ubuntu Git Maintainers PPA for the current stable branch, or download and build the upstream source archive when you need full control over the install.
Ubuntu uses the git package for the command-line client. You do not need a separate Git Bash download on Ubuntu because the normal Linux terminal already runs Git, and git clone comes from the same package after installation.
Install Git on Ubuntu
Start with the default APT package unless you specifically need a newer Git release than Ubuntu ships. The APT package is the lowest-maintenance path, while the PPA and source-build paths trade more control for more responsibility.
| Method | Version Source | Best For | Update Path |
|---|---|---|---|
| Ubuntu APT package | Ubuntu repository branch | Most desktops, servers, CI hosts, and stable environments | Normal apt upgrade |
| Git Maintainers PPA | Current stable Git release for Ubuntu | Users who need newer Git features or fixes while staying package-managed | Normal apt upgrade after the PPA is added |
| Source archive | Upstream Git tag in a managed /usr/local/git-<version> prefix | Testing, custom builds, or advanced development workflows | Helper script that installs the next versioned prefix |
These steps support Ubuntu 26.04 LTS (Resolute), Ubuntu 24.04 LTS (Noble), and Ubuntu 22.04 LTS (Jammy). Ubuntu 20.04 is outside this article’s active support scope because standard support ended in May 2025.
Update Ubuntu Packages Before Installing Git
Refresh APT metadata and apply pending package updates before installing Git:
sudo apt update && sudo apt upgrade
These commands use
sudobecause package installation changes system files. If your account cannot use sudo yet, follow the guide to add a new user to sudoers on Ubuntu or run the commands from an administrator account.
Check Whether Git Is Already Installed
Some developer images already include Git, but clean Ubuntu desktop, server, and minimal installs may not. Check the current state first:
git --version
If Git is missing, the shell returns an error similar to this:
Command 'git' not found, but can be installed with: sudo apt install git
Install Git from Ubuntu APT
Install the standard Ubuntu Git package with APT:
sudo apt install git
The older sudo apt-get install git command targets the same package. Use apt for interactive terminal examples on modern Ubuntu systems.
Verify the installed Git version:
git --version
Ubuntu 26.04 currently returns the 2.53 series from the default repository:
git version 2.53.0
The exact default branch depends on the Ubuntu release:
| Ubuntu Release | Default Git Package | Repository Component |
|---|---|---|
| 26.04 LTS (Resolute) | 2.53.x | Main |
| 24.04 LTS (Noble) | 2.43.x | Main |
| 22.04 LTS (Jammy) | 2.34.x | Main |
Use the package name git, not git-core. Current Ubuntu 26.04, 24.04, and 22.04 repositories do not provide a git-core candidate, so commands such as sudo apt install git-core fail even though the normal Git package is available.
Install Latest Stable Git from the Git Maintainers PPA
The Ubuntu Git Maintainers PPA publishes the current stable Git branch for supported Ubuntu releases. The PPA currently provides Git 2.54.0 for Resolute, Noble, and Jammy, while the default Ubuntu repositories stay on their release branches.
Install the repository helper if your system does not already include it:
sudo apt install software-properties-common
Add the Git Maintainers PPA:
sudo add-apt-repository ppa:git-core/ppa
Refresh APT metadata after adding the PPA:
sudo apt update
Install or upgrade Git from the PPA:
sudo apt install git
Confirm the new version:
git --version
git version 2.54.0
Check that APT now prefers the PPA package:
apt-cache policy git
Relevant output on Ubuntu 26.04 includes the PPA candidate and the older Ubuntu repository package below it:
git:
Installed: (none)
Candidate: 1:2.54.0-0ppa1~ubuntu26.04.1
Version table:
1:2.54.0-0ppa1~ubuntu26.04.1 500
500 https://ppa.launchpadcontent.net/git-core/ppa/ubuntu resolute/main amd64 Packages
1:2.53.0-1ubuntu1 500
500 http://archive.ubuntu.com/ubuntu resolute/main amd64 Packages
Build Git from Source Archive
Use the source archive when you need an upstream tag before package repositories catch up, want to test Git itself, or need custom build flags. For ordinary workstations and servers, the APT or PPA method is easier to update and remove.
Install the compiler, library headers, download tools, and Python runtime used by the helper script:
sudo apt install build-essential libssl-dev zlib1g-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip curl wget python3
Download the current stable source archive from the Git tags page. The commands below use v2.54.0; if the tags page lists a newer stable tag, substitute it consistently in the archive URL, output filename, extracted directory, and install prefix. The wget command examples guide explains the -O option if you want more download patterns.
wget https://github.com/git/git/archive/refs/tags/v2.54.0.tar.gz -O git-v2.54.0.tar.gz
Extract the archive. GitHub removes the leading v from the extracted directory name, so v2.54.0 becomes git-2.54.0:
tar -xzf git-v2.54.0.tar.gz
cd git-2.54.0
Compile Git with a versioned installation prefix under /usr/local. The -j "$(nproc)" option uses all available CPU cores:
make -j "$(nproc)" prefix=/usr/local/git-2.54.0 all
Install the compiled files into that managed prefix, then create a stable symlink for the git command. The guard stops before overwriting a custom non-symlinked /usr/local/bin/git file:
if [ -e /usr/local/bin/git ] && [ ! -L /usr/local/bin/git ]; then
echo "/usr/local/bin/git already exists and is not a symlink. Move it before continuing."
else
sudo make prefix=/usr/local/git-2.54.0 install
sudo ln -sfn /usr/local/git-2.54.0 /usr/local/git-current
sudo ln -sfn /usr/local/git-current/bin/git /usr/local/bin/git
fi
Refresh your shell’s command lookup table and verify the active Git binary:
hash -r
git --version
command -v git
git version 2.54.0 /usr/local/bin/git
The /usr/local/bin/git path points to the managed source build and wins over Ubuntu’s packaged /usr/bin/git in the standard PATH order. Keep one active method wherever possible so future version checks and troubleshooting stay predictable.
Create a Source-Build Update Script
Source builds do not receive APT security or bug-fix updates. Create a reusable helper that checks the latest stable Git tag, skips release-candidate tags, rebuilds only when needed, and installs each release into its own versioned prefix:
mkdir -p ~/git-source-build
cat > ~/git-source-build/update-git.sh <<'SCRIPT'
#!/bin/bash
set -euo pipefail
INSTALL_PREFIX="/usr/local"
BUILD_DIR="$HOME/git-source-build"
CURRENT_LINK="$INSTALL_PREFIX/git-current"
BIN_LINK="/usr/local/bin/git"
if [ "$(id -u)" -eq 0 ]; then
echo "Run this script as your regular user. It will ask for sudo only during install."
exit 1
fi
for cmd in curl python3 tar make gcc grep nproc readlink sudo; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "Error: $cmd is required."
echo "Run: sudo apt install build-essential libssl-dev zlib1g-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip curl python3"
exit 1
fi
done
if [ -x "$CURRENT_LINK/bin/git" ]; then
CURRENT_VERSION=$("$CURRENT_LINK/bin/git" --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -n 1 || true)
else
CURRENT_VERSION=""
fi
CURRENT_VERSION=${CURRENT_VERSION:-none}
echo "Checking for latest stable Git tag..."
if ! LATEST_TAG=$(python3 - <<'PY'
import json
import re
import urllib.request
with urllib.request.urlopen("https://api.github.com/repos/git/git/tags") as response:
tags = json.load(response)
for tag in tags:
name = tag.get("name", "")
if re.fullmatch(r"v[0-9]+\.[0-9]+\.[0-9]+", name):
print(name)
break
else:
raise SystemExit("No stable Git tag found")
PY
); then
echo "Error: Could not fetch a stable Git tag from GitHub."
exit 1
fi
LATEST_VERSION=${LATEST_TAG#v}
echo "Current version: $CURRENT_VERSION"
echo "Latest available: $LATEST_VERSION"
if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then
echo "Already up to date."
exit 0
fi
if ! sudo true; then
echo "Error: sudo access is required for installation under /usr/local."
exit 1
fi
if [ -e "$BIN_LINK" ] && [ ! -L "$BIN_LINK" ]; then
echo "Error: $BIN_LINK already exists and is not a symlink."
echo "Move it before running this source-build updater."
exit 1
fi
if [ -e "$CURRENT_LINK" ] && [ ! -L "$CURRENT_LINK" ]; then
echo "Error: $CURRENT_LINK already exists and is not a symlink."
echo "Move it before running this source-build updater."
exit 1
fi
TARGET_PREFIX="$INSTALL_PREFIX/git-$LATEST_VERSION"
if [ -e "$TARGET_PREFIX" ]; then
echo "Error: $TARGET_PREFIX already exists."
echo "Move or remove that directory before reinstalling the same Git version."
exit 1
fi
ARCHIVE="git-${LATEST_TAG}.tar.gz"
URL="https://github.com/git/git/archive/refs/tags/${LATEST_TAG}.tar.gz"
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
rm -rf git-[0-9]*/
echo "Downloading $LATEST_TAG..."
curl -fL --progress-bar -o "$ARCHIVE" "$URL"
tar -xzf "$ARCHIVE"
rm -f "$ARCHIVE"
cd "git-${LATEST_VERSION}"
echo "Compiling Git $LATEST_VERSION..."
make -j "$(nproc)" prefix="$TARGET_PREFIX" all
echo "Installing Git $LATEST_VERSION..."
sudo make prefix="$TARGET_PREFIX" install
PREVIOUS_TARGET=""
if [ -L "$CURRENT_LINK" ]; then
PREVIOUS_TARGET=$(readlink "$CURRENT_LINK")
fi
sudo ln -sfn "$TARGET_PREFIX" "$CURRENT_LINK"
sudo ln -sfn "$CURRENT_LINK/bin/git" "$BIN_LINK"
hash -r
if ! NEW_VERSION=$("$BIN_LINK" --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -n 1); then
echo "Error: installed Git did not run correctly."
if [ -n "$PREVIOUS_TARGET" ]; then
sudo ln -sfn "$PREVIOUS_TARGET" "$CURRENT_LINK"
else
sudo rm -f "$CURRENT_LINK" "$BIN_LINK"
fi
exit 1
fi
echo "Successfully installed Git $NEW_VERSION"
SCRIPT
chmod +x ~/git-source-build/update-git.sh
Run the helper whenever you want to check for a newer source release:
~/git-source-build/update-git.sh
When the installed version already matches the latest stable tag, the script stops without rebuilding:
Checking for latest stable Git tag... Current version: 2.54.0 Latest available: 2.54.0 Already up to date.
Do not run source-build updates from cron. Compilation can fail because of network outages, GitHub API limits, missing libraries, or local build errors, and those failures need interactive review.
Configure Git on Ubuntu
Git needs a username and email address before it can create commits. Use the same email address you use on GitHub, GitLab, or Bitbucket if you want web interfaces to connect commits to your account.
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
The detailed guide to configure Git username and email values covers per-repository overrides, privacy addresses, and common identity mistakes.
Set a few practical defaults for new repositories and terminal output:
git config --global init.defaultBranch main
git config --global core.editor nano
git config --global color.ui auto
Verify the global configuration:
git config --global --list
user.name=Your Name user.email=your.email@example.com init.defaultbranch=main core.editor=nano color.ui=auto
Your global configuration lives in ~/.gitconfig. Back it up if you add aliases, signing keys, credential helpers, or editor settings that you rely on across multiple Ubuntu systems.
Set Up SSH Authentication for Git
Git itself does not have a universal git login command. For GitHub, GitLab, and Bitbucket, the usual choices are SSH keys or HTTPS with a personal access token. SSH avoids repeated password prompts and keeps credentials out of plain-text helper files.
ssh-keygen -t ed25519 -C "your.email@example.com"
Add the public key from ~/.ssh/id_ed25519.pub to your hosting account, then use SSH remote URLs such as git@github.com:OWNER/REPOSITORY.git. The Ubuntu SSH setup guide covers key handling in more detail if you need to install and enable SSH on Ubuntu.
If you prefer GitHub’s browser-based login flow, install the GitHub CLI and run gh auth login. The guide to install GitHub CLI on Ubuntu covers that separate tool.
Troubleshoot Git on Ubuntu
Git Command Not Found
If the terminal cannot find Git, install the git package and open a new shell or refresh the shell command cache:
sudo apt install git
hash -r
git --version
Package git-core Is Not Available
Older tutorials may still mention git-core, but current supported Ubuntu LTS releases use git as the installable package name. If APT reports that git-core has no installation candidate, install git instead:
sudo apt install git
Author Identity Unknown
Git refuses to create commits until user.name and user.email are configured. A failed commit often prints this message:
Author identity unknown *** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. fatal: unable to auto-detect email address
Set the missing values globally, then retry the commit:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
Password Authentication Is Not Supported
GitHub no longer accepts account passwords for Git operations over HTTPS. When an HTTPS remote prompts for a password, you may see an error like this after entering old credentials:
remote: Invalid username or token. Password authentication is not supported for Git operations. fatal: Authentication failed for 'https://github.com/OWNER/REPOSITORY.git/'
Switch the remote to SSH after adding your SSH key to the hosting account:
git remote -v
git remote set-url origin git@github.com:OWNER/REPOSITORY.git
git remote -v
HTTPS can still work with a personal access token, but avoid credential.helper store unless you understand that it writes credentials in plain text under your home directory.
Git LFS Is Not a Git Command
Git Large File Storage is a separate package. If a repository requires LFS and Git prints git: 'lfs' is not a git command, install git-lfs from Ubuntu’s Universe component:
sudo apt install git-lfs
git lfs install
If APT cannot locate git-lfs on a minimal system, enable the repository component first with the guide to enable Universe and Multiverse on Ubuntu. Only Universe is needed for git-lfs.
Update or Remove Git on Ubuntu
Update APT or PPA Git Packages
Update Git installed from Ubuntu’s repository or the Git Maintainers PPA through the normal APT upgrade path:
sudo apt update && sudo apt upgrade
To upgrade only Git when it is already installed, use APT’s single-package upgrade form:
sudo apt install --only-upgrade git
Update Source-Built Git
Run the helper script created in the source-build section:
~/git-source-build/update-git.sh
Remove APT or PPA Git Packages
Remove the package-managed Git installation first:
sudo apt remove git
Verify the package is no longer installed:
dpkg -l git | grep '^ii' || echo "git package is not installed"
git package is not installed
If you added the Git Maintainers PPA, remove it and refresh APT metadata:
sudo add-apt-repository --remove ppa:git-core/ppa
sudo apt update
The dedicated guide to remove a PPA from Ubuntu covers additional cleanup options such as purging packages back to Ubuntu repository versions.
Remove Source-Built Git
Source builds installed with make install are not tracked by APT. Review the managed source-build paths before deleting anything:
find /usr/local -maxdepth 1 \( -type d -o -type l \) \( -name 'git-[0-9]*' -o -name 'git-current' \) -print
ls -l /usr/local/bin/git 2>/dev/null || true
The removal block permanently deletes versioned Git source-build prefixes under
/usr/local, the/usr/local/git-currentsymlink, the article-created/usr/local/bin/gitsymlink, and the helper directory in your home folder. Do not run it if you intentionally keep custom directories with the same/usr/local/git-<version>naming pattern.
sudo rm -f /usr/local/bin/git
sudo rm -f /usr/local/git-current
sudo rm -rf /usr/local/git-[0-9]*
rm -rf ~/git-source-build git-v*.tar.gz git-[0-9]*
hash -r
Confirm which Git binary, if any, remains active:
command -v git || echo "git command not found"
git command not found
Conclusion
Git is ready on Ubuntu with the package source that matches your maintenance needs: Ubuntu’s default branch for stability, the Git Maintainers PPA for the current stable release, or a source build for controlled testing. From here, switch Git branches safely or install GitHub CLI on Ubuntu for repository work from the terminal.


Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed in published comments:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>