Oct 12, 2023 4 min read

How to Install Git on Raspberry Pi

Install Git on Raspberry Pi with our step-by-step tutorial. It is a popular open-source distributed version control system.

Install Git on Raspberry Pi
Table of Contents

Choose a different version or distribution


Before we begin talking about how to install Git on Raspberry Pi, let’s briefly understand - What is Git?

Git is a popular open-source distributed version control system that can handle a number of things right from small to very large projects with great speed and efficiency. The fact that it is user-friendly and easy to learn makes it stand out. If you have a Raspberry Pi, installing Git on it can greatly enhance your ability to work on projects, share code, and contribute to open-source development.

In this tutorial, you will install Git on Raspberry Pi enabling you to utilize the powerful features of Git for your coding projects. We will also address a few FAQs on how to install Git on Raspberry Pi.

Advantages to install Git on Raspberry Pi

  1. Version Control: Git allows you to track changes made to your code or any other files. It provides a history of modifications, allowing you to easily revert to previous versions if needed.
  2. Collaboration: Git enables seamless collaboration among multiple developers by providing features like branching and merging.
  3. Code Sharing and Open-Source Contributions: With Git, sharing your code with others becomes convenient. Git simplifies the process of making contributions to existing projects and managing pull requests.
  4. Backup and Disaster Recovery: By using Git, you can easily create backups of your code or important files. Git repositories can be cloned or pushed to remote servers, ensuring that your data is stored safely.
  5. Project Organization and Documentation: Git allows you to manage your project structure effectively. You can create branches, tags, and commit checkpoints to organize your work.

Install Git with Apt

The default Raspbian repositories include the Git package.

To install Git on your Raspberry Pi, run the following command as root or as a user with sudo privileges:

sudo apt update
sudo apt install git

To check the installation, run the command below:

git --version

The current version of Git available in the Raspberry Pi repositories is 2.20.1 at the time of writing this article.


git version 2.20.1

You have successfully installed Git and are ready to use it.

Install Git from the Source

You can install the newest Git version and change the build options by compiling Git from the source. However, you won't be able to use the apt package manager to maintain your Git installation.

Begin by installing the required requirements for building Git on Raspbian:

sudo apt update
sudo apt install make libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev gettext

After the installation is complete, go to the Git project's GitHub mirror and copy the latest release link URL that ends in .tar.gz:

Currently, the most recent stable Git version is 2.24.1, but it may be different for you.

We are going to download the Git source in the /usr/src directory, which is the common location to place source files. Navigate to the directory:

cd /usr/src/

Using the link you copied before, download the tar.gz file as git.tar.gz:

sudo wget https://github.com/git/git/archive/v2.24.1.tar.gz -O git.tar.gz

After that, extract the tarball and navigate to the git source directory using the following command:

sudo tar -xf git.tar.gz
cd git-*

To compile and install Git, use the following two commands:

sudo make prefix=/usr/local all
sudo make prefix=/usr/local install

To check the installation, type git --version:

git --version

git version 2.24.1

When a new version is released, download the archive and repeat the build procedure to update Git.

Configuring Git

It's a good idea to set up your personal information now that Git is installed on your Raspberry Pi system. Set your commit name and email address with the scripts below:

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

To make sure you've entered your information correctly in Git, type:

git config --list

user.name=Your Name
[email protected]

The /.gitconfig file stores the configuration settings:

    name = Your Name
    email = [email protected]

Use the git config command or manually modify the /.gitconfig file to make additional changes to the global Git settings.

FAQ's to install Git on Raspberry Pi

What version of Raspberry Pi supports Git?

Git can be installed on various versions of Raspberry Pi, including the Raspberry Pi 2, 3, 4, and Zero.

How can I check if Git is already installed on my Raspberry Pi?

You can check if Git is already installed by opening a terminal and typing git --version. If Git is installed, it will display the installed version; otherwise, an error message will be shown.

What is the purpose of using 'sudo' while installing Git? 

'sudo' (Superuser Do) is used to execute commands with administrative privileges. Installing Git requires administrative access to the operating system, hence the use of 'sudo'.

What are the advantages of using Git on Raspberry Pi? 

Using Git on Raspberry Pi allows you to easily track changes, manage versions of your code, collaborate with others, and contribute to open-source projects.

Will installing Git on Raspberry Pi overwrite any existing repositories? 

No, installing Git does not affect any existing repositories on your Raspberry Pi. You can continue working with your repositories without any changes.

Can multiple users on Raspberry Pi access and use Git? 

Yes, multiple users on Raspberry Pi can access and use Git independently. Each user can create and manage their own repositories or collaborate on shared repositories.

Can I use Git commands and features on Raspberry Pi without an internet connection? 

Yes, you can use Git on your Raspberry Pi without an internet connection. Git works locally on your machine, allowing you to manage repositories, commit changes, and switch between branches.

Can I update Git to the latest version on Raspberry Pi?

Yes, you can update Git to the latest version on Raspberry Pi by running the command: sudo apt update && sudo apt upgrade git.

How can I uninstall Git from Raspberry Pi? 

To uninstall Git from Raspberry Pi, open the terminal and run the command: sudo apt remove git.


With Git's version control system, you can track changes, revert to previous versions, and effectively manage your code or files. The ability to collaborate with teammates and contribute to open-source projects is simplified through features like branching and merging. Git also provides a convenient way to share code and backup important files, ensuring disaster recovery and data preservation.

You may set up your own Git server on your local network using a Raspberry Pi by following the steps mentioned in the tutorial.

If you run into any issues or have any feedback, please leave a remark below.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Blog - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.