How to Install Git on Raspberry Pi

Git is a distributed version control system used by most software teams today. It allows you to keep track of your code changes, revert to previous stages, create branches , and collaborate with your fellow developers.
Git was originally developed by Linus Torvalds , the creator of the Linux kernel.
This guide explains how to install Git on Raspberry Pi OS. It assumes you have Raspberry Pi OS installed on your Raspberry Pi .
For most users, the easiest and recommended way to install Git is through the apt
package manager. If you need the latest stable version, scroll down to the Installing Git from Source
section.
Quick Reference
For a printable quick reference, see the Git cheatsheet .
| Command | Description |
|---|---|
sudo apt install git | Install Git from the Raspberry Pi OS repositories |
git --version | Verify the installed version |
git config --global user.name "Name" | Set your commit name |
git config --global user.email "email" | Set your commit email |
git config --list | View current Git configuration |
Installing Git with Apt
The Git package is included in the Raspberry Pi OS default repositories.
Run the following commands as root or a user with sudo privileges to install Git:
sudo apt update
sudo apt install gitOnce the installation is complete, verify it by running:
git --versiongit version 2.39.2Git is now installed and ready to use.
Installing Git from Source
Compiling Git from source allows you to install the latest version and customize build options. However, a source-based installation is not managed by apt, so updates require repeating the build process manually.
Start by installing the build dependencies:
sudo apt update
sudo apt install make libssl-dev zlib1g-dev libcurl4-gnutls-dev libexpat1-dev gettextNext, visit the Git releases page on GitHub
and note the latest release tag. Set that version in the GIT_VERSION variable in the command below. We are downloading the source to /usr/src, a common location for source files:
cd /usr/src/
GIT_VERSION="X.Y.Z"
sudo wget "https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz" -O git.tar.gzExtract the archive and change to the source directory:
sudo tar -xf git.tar.gz
cd "git-${GIT_VERSION}"Compile and install Git:
sudo make prefix=/usr/local all
sudo make prefix=/usr/local installVerify the installation:
git --versionTo update Git in the future, download the newer release archive from the releases page and repeat the build process.
Configuring Git
After installation, set your identity. Git attaches this information to every commit you make.
git config --global user.name "Your Name"
git config --global user.email "youremail@yourdomain.com"To confirm the settings, run:
git config --listuser.name=Your Name
user.email=youremail@yourdomain.comThe configuration is stored in the ~/.gitconfig file:
[user]
name = Your Name
email = youremail@yourdomain.comFor more options, see How to Configure Git Username and Email .
Troubleshooting
git: command not found after a source install
The source installation places the binary in /usr/local/bin. Run echo $PATH to confirm that directory is included. If it is missing, add export PATH="/usr/local/bin:$PATH" to ~/.bashrc and reload with source ~/.bashrc.
Build fails with missing dependency errors
Ensure all build dependencies installed without errors before compiling. Re-run the apt install command from the source section, check the output for any failures, and retry.
The apt version is older than expected
The Raspberry Pi OS repositories do not always ship the latest Git release. If you need a newer version than apt provides, use the source installation method instead.
git config settings are not taking effect
The --global flag writes to ~/.gitconfig and applies to all repositories for your user. Without it, settings apply only to the current repository. Run git config --list --show-origin to see which config files are active and where they are stored.
FAQ
Should I install from apt or from source?
Use apt for most cases. It is simpler, the package manager handles updates, and security patches are applied automatically. Install from source only when you need a version newer than what the repositories provide.
How do I update Git installed from source?
Download the newer release archive from the Git releases page
, extract it, and repeat the make commands. The new binary replaces the previous one in /usr/local/bin.
How do I uninstall Git?
If installed via apt, run sudo apt remove git. If installed from source, remove the binary manually with sudo rm /usr/local/bin/git along with any associated files in /usr/local.
Can I use Raspberry Pi as a Git server?
Yes. With a minimal server setup you can set up your own Git server
on your local network using your Raspberry Pi.
Conclusion
You have installed Git on Raspberry Pi OS using apt or built the latest version from source. Set your identity with git config before making your first commit.
If you have any questions, feel free to leave a comment below.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page