instalar-git-en-raspberry-pi

How to Install and Use Git on Raspberry Pi

  • 3 min

Git is a distributed version control system that lets us save the history of changes in a project and work with local or remote repositories.

Configuring Git on Raspberry Pi lets us use it as a development machine, clone projects, sync code, and keep our changes much more organized.

What is Git

Git is a distributed version control system created by Linus Torvalds in 2005. Git allows you to:

  • Track changes: Keep a record of changes made to the source code over time.
  • Branching and merging: Work on different development branches and merge them efficiently.
  • Collaboration: Facilitate collaboration among multiple developers on the same project.

Git is essential for managing software projects, both large and small, from personal projects to team collaborations.

Installing Git

First, we update the system before installing new packages. Open the terminal and run the following commands:

sudo apt update sudo apt upgrade

Then, install Git, which is available in the Debian and Raspberry Pi OS repositories, using this command:

sudo apt install git

To verify that Git has been installed correctly, check its version with:

git —version

We should see a message similar to git version 2.x.x, where 2.x.x is the installed version.

Initial Git Configuration

After installing Git, perform a basic configuration to personalize user information. This configuration is used in commits to identify who made the changes.

Set your name and email with the following commands. Replace "Your Name" and "[email protected]" with your information:

git config —global user.name “Your Name” git config —global user.email “[email protected]

These settings are stored in the ~/.gitconfig file and apply to all Git repositories for your user.

To confirm that the configuration has been applied correctly, use the following command:

git config —list

You should see the user information you configured, along with other default settings.

Basic Git Usage

With Git installed and configured, you can start working with repositories. Below are some basic commands to familiarize yourself with the Git workflow.