This Git Tutorial explains how to install Git on Ubuntu is one of the most essential first steps for any developer, student, DevOps engineer, or open-source contributor working on Linux — Git is the world’s most popular distributed version control system, powering platforms like GitHub, GitLab, Bitbucket, and almost every serious software project in 2025–2026. Whether you’re starting a new repo, cloning existing projects, collaborating with teams, or preparing for interviews/certifications, having Git properly installed and configured on Ubuntu is non-negotiable.
In this up-to-date 2025–2026 Progressive Robot guide, you’ll master exactly how to install Git on Ubuntu using two proven methods: the fast apt package manager (recommended for most users) and compiling from source (for the absolute latest version or custom builds). You’ll also complete the critical first-time setup, verify everything works, troubleshoot common issues, and learn how to uninstall cleanly if needed.
Git Tutorial– How to Install Git on Ubuntu
- Use sudo apt install git for the quickest, most stable installation
- Compile from source if you need the newest features or specific version
- Always configure user.name and user.email after installation
- Set init.defaultBranch main — modern standard (replaces old “master”)
- Verify with git –version after every install method
- Git works identically on Ubuntu Desktop, Server, and WSL (Windows Subsystem for Linux)
Git Tutorial – Prerequisites
- Ubuntu 20.04, 22.04, 24.04, or 25.04 (LTS or latest)
- Non-root user with sudo privileges
- Terminal access (Ctrl+Alt+T or SSH session)
- Internet connection for package downloads
Method 1: Install Git on Ubuntu Using apt (Recommended – Fast & Stable)
This is the easiest, most reliable way for 95% of users — you get a stable, security-patched version maintained by Ubuntu.
- Update package index
sudo apt update
2. Install Git
sudo apt install git -y
3. Verify installation
git --version
You should see output like:
git version 2.34.1 # or newer (Ubuntu 22.04+ usually has 2.34–2.45+)
Done! You now have Git installed on Ubuntu via apt.
Want the very latest version? Add the official Git PPA:
sudo add-apt-repository ppa:git-core/ppa -y
sudo apt update
sudo apt install git -y
This usually gives you Git 2.46+ in 2025–2026.
Method 2: Install Git on Ubuntu from Source (Latest Version / Custom Build)
Use this method when you need features not yet in Ubuntu repos (e.g., new git rebase –update-refs, improved sparse-checkout).
- Install build dependencies
sudo apt update
sudo apt install -y dh-autoreconf libcurl4-gnutls-dev libexpat1-dev gettext \
libz-dev libssl-dev asciidoc xmlto docbook2x install-info autoconf \
automake libtool pkg-config tcl tk libpcre2-dev
- Download latest Git source
Check https://mirrors.edge.kernel.org/pub/software/scm/git/ for the newest version (e.g., git-2.51.0.tar.gz as of late 2025).
cd ~
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.51.0.tar.gz
tar -zxf git-2.51.0.tar.gz
cd git-2.51.0
- Compile and install
make prefix=/usr/local all doc info
sudo make prefix=/usr/local install install-doc install-html install-info
- Verify
git --version
You should see the exact version you downloaded (e.g., git version 2.51.0).
3. First-Time Git Configuration (Mandatory!)
After installation, set your identity — Git embeds this in every commit:
git config --global user.name "Zain Ahmed"
git config --global user.email "zain@example.com"
Modern default branch name (replaces old “master”):
git config --global init.defaultBranch main
Optional useful settings:
git config --global core.editor "nano" # or "code", "vim"
git config --global color.ui auto # colored output
git config --global pull.rebase false # merge on pull
Check all settings:
git config --global --list
4. Git Tutorial – Common Mistakes & Troubleshooting
- “Command ‘git’ not found” after install → Restart terminal or run exec bash / source ~/.bashrc
- Old version from apt → Use PPA method or compile from source
- Permission denied during source install → Use sudo make prefix=/usr/local install
- Conflicts from multiple installs → Remove apt version first: sudo apt remove git, then install from source
- WSL Ubuntu install fails → Same commands work — make sure WSL has internet & sudo access
Git Tutorial– FAQs (2026)
- How do I install Git on Ubuntu 24.04 / 25.04?
sudo apt update && sudo apt install git -y - How do I get the latest Git on Ubuntu?
Add PPA: sudo add-apt-repository ppa:git-core/ppa && sudo apt update && sudo apt install git - How do I install Git from source on Ubuntu?
Install dependencies → download tarball → make prefix=/usr/local all && sudo make install - How do I configure Git after installation?
git config –global user.name “Your Name”git config –global user.email “[email protected]” - How do I uninstall Git on Ubuntu?
apt: sudo apt remove –purge git Source: cd source-dir && sudo make uninstall
Summary
After reading Git tutorial you now know exactly how to install Git on Ubuntu: fast apt method, latest source compile, full configuration, verification, and troubleshooting.
Mastering how to install Git on Ubuntu unlocks version control — the foundation of modern development, collaboration, open-source contributions, and DevOps workflows.
You’re ready to start using Git! Next steps:
- Create your first repo: git init my-project
- Clone a project: git clone https://github.com/username/repo.git
- Learn branching: git branch, git checkout -b feature/new-ui
- Push to GitHub/GitLab