How to install Git on Linux: Ubuntu, Debian, Fedora and Arch
Install Git on Linux with your distribution's command (apt, dnf, pacman or zypper), get the latest version on Ubuntu and check that it works.
On Ubuntu or Debian, installing Git is sudo apt update followed by sudo apt install git, typed in the terminal (on Ubuntu, Ctrl + Alt + T):
sudo apt update
sudo apt install git
Each Linux family has its own package manager (the program that installs and updates software from your distribution’s repositories, like an app store you run from the terminal), so the command changes, but the idea is the same. If you’re still not sure what you want Git for, start with what Git is and why you’ll use it.
Which command installs Git on my distribution?
It depends on your distro’s family, not on its brand name. Linux Mint, for example, belongs to the Ubuntu family and uses apt.
| Distribution | Package manager | Command |
|---|---|---|
| Ubuntu, Debian and derivatives like Linux Mint | apt | sudo apt update and then sudo apt install git |
| Fedora | dnf | sudo dnf install git |
| Arch, Manjaro | pacman | sudo pacman -S git |
| openSUSE | zypper | sudo zypper install git |
Before you install anything, type git --version: if it answers with a number, you already have it (this happens on many servers and on WSL) and you can skip to the section on checking the installation.
These are the commands listed on Git’s official page for Linux [1], with sudo in front and, on Ubuntu and Debian, with apt update run first.
sudo means “run this as administrator” and it will ask for your password (you won’t see anything as you type it, not even asterisks; that’s normal). apt update doesn’t update any program: it only downloads the list of available packages, which is why it goes first. Then the package manager shows you what it’s going to download and usually asks for confirmation: type y and press Enter (on a system set to another language, the letter may be different).
If you don’t know which distro you have, ask the system:
# Shows the name and version of your distribution
cat /etc/os-release
Look at NAME and ID_LIKE: the second one tells you the family (on Ubuntu it says debian), which is what decides your row in the table.
How do I install Git on Debian and Fedora?
On Debian, Git is installed with the same two commands as on Ubuntu: sudo apt update and sudo apt install git. The PPA from the section on the latest version is only for Ubuntu, not for Debian. On Fedora, sudo dnf install git is enough, with no step before it: dnf refreshes its package list on its own when it has expired.
Why does apt install git give me an old version?
Because Ubuntu locks the version of almost every program the day each release ships, and from then on it only accepts updates in specific circumstances, mostly security patches and bug fixes [2]. It’s a deliberate decision: someone running a server on Ubuntu 24.04 wants nothing to change behavior by surprise.
I checked it on a machine running Ubuntu 24.04 while writing this:
# Which version of Git I have and where it comes from
git --version
# git version 2.43.0
which git
# /usr/bin/git
Ubuntu 24.04 shipped in April 2024 with Git 2.43.0, and in November 2026 its repository is still on 2.43.0, now at revision 1ubuntu7.4 [3]. Meanwhile, the Git project is already on the 2.56 series. The newer your Ubuntu, the smaller the gap: 26.04 comes with Git 2.53.0 [3].
Is that a problem? For learning and for day-to-day work, almost never. Everything you’ll use at the beginning (commit, branches, merge, push) works the same in 2.43. You’ll need a newer one the day a tool asks for a minimum Git version or a tutorial uses an option your Git doesn’t recognize.
How do I install the latest version of Git on Ubuntu?
With the PPA from the team that packages Git for Ubuntu. A PPA (Personal Package Archive) is an extra repository, hosted on Launchpad, with versions the official repository doesn’t carry. Git’s is called ppa:git-core/ppa and its own page describes it as “The most current stable version of Git for Ubuntu” [4]:
# Adds the stable Git repository
sudo add-apt-repository ppa:git-core/ppa
# Refreshes the package list so apt can see it
sudo apt update
# Installs Git (or upgrades it if you already had it)
sudo apt install git
The first command shows you the PPA’s description and stops at Press [ENTER] to continue: press Enter to add it. As I write this, the PPA offers Git 2.56.1 for Ubuntu 24.04, uploaded on November 11, 2026 [4].
Now for the judgment call. Launchpad warns that these are “unsupported” packages from an “untrusted” PPA [4], the same warning it shows on other PPAs: they aren’t part of Ubuntu and Ubuntu doesn’t vouch for them. Adding one means trusting whoever maintains it, because its packages get installed as administrator every time you update. This is the one Git’s own install page gives for Ubuntu [1], so it’s among the trustworthy ones, but the decision is yours: on your laptop, go ahead; on a server you don’t administer, I wouldn’t add it without asking.
How do I check that Git was installed correctly on Linux?
With the same git --version as before: if it answers with a number, Git is installed. If you’re coming from the PPA, that number should already be the new one, because its Git replaces the previous one at /usr/bin/git instead of being installed next to it.
To see which version you have and which one the repositories offer you, Ubuntu has apt-cache policy git. You’ll see something like this:
apt-cache policy git
# git:
# Installed: 1:2.43.0-1ubuntu7.4
# Candidate: 1:2.43.0-1ubuntu7.4
If Candidate is higher than Installed, there’s an update pending.
How do I update Git on Ubuntu?
It depends on what you’re after: sudo apt install --only-upgrade git brings you the patches for your Ubuntu’s version, and moving to a new version of Git takes the PPA. For the patches, refresh the list and upgrade only Git:
sudo apt update
# Upgrades Git and nothing else; sudo apt upgrade would upgrade the whole system
sudo apt install --only-upgrade git
That brings patches, but the number doesn’t move: on Ubuntu 24.04 you’ll still be on 2.43.0. For a new version of Git, add the ppa:git-core/ppa PPA (previous section); from then on, those same two commands, or a sudo apt upgrade of the whole system, bring you every version they publish. On other families, Git is updated along with the system: sudo dnf upgrade on Fedora, sudo pacman -Syu on Arch and sudo zypper update on openSUSE Leap.
How do I install Git on WSL?
Chances are you already have it: according to Microsoft, most WSL distributions come with Git installed [5]. Check with git --version inside the WSL terminal. If it’s missing or you want to update it, the commands are the same as on any Ubuntu:
sudo apt update
sudo apt install git
That said, that Git is not the Windows one. WSL (Windows Subsystem for Linux) gives you a complete Linux distribution inside Windows (Ubuntu by default), and its Git is a Linux program; Git for Windows, the one from the guide to installing Git on Windows, is a different one. Microsoft says it plainly: you have to install Git on each file system where you’re going to use it [5], on Windows and on your WSL distribution, and each one keeps its own configuration. If your projects live inside WSL, use WSL’s Git, and set your name and email in both if you use both.
Common errors when installing Git on Linux
sudo: apt: command not found
You’re using another family’s command. apt belongs to Debian and Ubuntu; on Fedora it isn’t installed. Look at cat /etc/os-release and use your distro’s row in the table.
E: Unable to locate package git
Git exists, but your system doesn’t know yet which packages are available to it. It happens a lot in Docker containers and minimal images. The fix is to run sudo apt update first, which is exactly why the table puts it in front.
Permission denied from forgetting sudo
If you run apt install git without sudo, apt can’t lock the package database and it tells you so like this:
apt install git
# E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
# E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
That “are you root?” is the clue. Run the command again with sudo in front.
sudo: add-apt-repository: command not found
Minimal Ubuntu installations (containers, some servers) don’t include that command. It comes in the software-properties-common package: install it with sudo apt install software-properties-common and go back to the PPA step.
What do I do after installing Git?
With Git installed, the next step is telling it who you are: your name and email are recorded in every commit. You’ll find it in the guide to setting up your name and email in Git, and it takes two minutes. If you also work on a Mac, the guide to installing Git on macOS covers that case.
And if from here you’d like a guided path instead of one standalone guide after another, the course Git: From Zero to Professional starts right at this point and, with exercises, gets you working on a team with branches.
Sources
- Install for Linux (git-scm.com): commands per distribution and the PPA for Ubuntu.
- Stable Release Updates (Ubuntu Project documentation): which updates stable releases receive.
- git source package in Ubuntu (Launchpad): the Git version in each Ubuntu release.
- Git stable releases, Ubuntu Git Maintainers PPA (Launchpad): the PPA’s commands, warning and versions.
- Get started using Git on Windows Subsystem for Linux (Microsoft Learn): Git on WSL distributions.
- INSTALL (official Git repository): building Git from source.
- Pro Git, Installing Git: installing Git on Linux with the package manager.
Frequently Asked Questions
Do I have to build Git from source to get the latest version?
Almost never. On Ubuntu the PPA gives you the latest stable version without compiling anything, and building it forces you to install dependencies and to update it by hand every time. If you need it anyway, the INSTALL file in the official Git repository explains the process [6].
How do I install Git on a Linux server where I don’t have sudo?
The first thing is to ask whoever administers the machine, because chances are Git is already installed or they can install it in a minute. If that’s not possible, Git can be built and installed in your home folder: according to the project’s INSTALL file, make followed by make install installs the programs in your ~/bin directory without touching the system [6].
It only works if the machine already has a compiler and the libraries Git needs, and if ~/bin is in your PATH; if anything is missing, you’re back to depending on whoever administers it. Updates are also on you.
How do I uninstall Git on Ubuntu?
With apt remove, which lists what it’s going to remove and asks for confirmation before deleting anything. If you added the PPA, remove it too:
sudo apt remove git
# Only if you added the PPA
sudo add-apt-repository --remove ppa:git-core/ppa
sudo apt update
Your repositories and your ~/.gitconfig aren’t touched: they live in your home folder, not in the package. And if you only remove the PPA, without uninstalling, the version you have stays; it just stops being updated from there.
Can I install Git with snap or flatpak?
You don’t need to: both Git’s official page [1] and the Pro Git book [7] point to your distribution’s package manager, which is what keeps Git up to date along with the rest of the system.