Skip to content

Prologue

Version control is an essential tool in software development, allowing teams to efficiently manage, track, and collaborate on code. This Git guide is designed for those taking their first steps in using Git, a widely recognized distributed version control system.

In the following pages, you will learn how to configure Git in your development environment and use its basic commands to manage your projects. From creating your first repository to tracking changes and collaborating in a team, this guide aims to provide you with a solid foundation in using Git.

However, there are two alternative ways to use this material that are important to clarify:

First:
If you only want to learn about the most frequently used concepts when working with this tool, you can go to Chapter 2. Git Terminology, where the most important concepts are defined.

Second:
If you are already familiar with Git and only need a command guide, you can go to Chapter 10. Command Glossary, which lists the most commonly used commands when working with Git along with a brief description of their use.


1. Introduction

Modern software development is increasingly conducted on larger scales, creating collaborative code that extends across hundreds or even thousands of lines. Many of these lines are constantly modified, making it necessary—almost essential—to use tools that allow us to efficiently manage changes in the code, whether made by ourselves or by our team.

Git has become one of the indispensable tools in this field, facilitating project organization and ensuring that we, as developers, can work effectively both individually and collaboratively.

The goal of this manual is to introduce Git to developers who have not yet used it.

1.1 What is Git?

Git is a distributed version control system, which means it allows us to manage, monitor, and coordinate a system composed of various nodes (servers, workstations, personal devices) that are interconnected and function as a single entity, even if they are physically located in different places.

Git was created by Linus Torvalds in 2005, with the goal of improving the way teams collaborate and maintain code (primarily for the development of the Linux kernel). Unlike centralized version control systems, Git allows us (and the rest of our team members) to have a complete copy of the project's history on our local machine, providing greater flexibility and speed in our work.

Its popularity has grown enormously, in part due to platforms such as GitHub and GitLab, which have made collaboration and code distribution more accessible.

1.2 Benefits of Using Git

Using Git offers multiple benefits, both for individual development and for large teams. Some of the most notable include:

  • Efficient Collaboration: Facilitates teamwork by allowing multiple developers to work on the same project simultaneously without the risk of overwriting each other's work.

  • Complete Change History: Git stores a detailed history of all changes made to the code, allowing developers to track bugs, review previous versions, and understand the project's evolution over time.

  • Distributed Control: Since Git is a distributed system, each developer has a full copy of the repository, meaning they are not dependent on a central server to perform their work. This provides greater independence and security, as work is not lost if the central server fails.

  • Flexibility and Customization: Git offers a set of tools that can be adapted to the specific workflows of each team or project. Developers can customize how and when they want to integrate changes, as well as define their own code review processes.

  • Parallel Development with Branches: Git facilitates parallel development through the use of branches. Branches allow for the creation of alternative versions of a project, where developers can experiment with new features or make fixes without affecting the main codebase. This is especially useful for managing different software versions or working on multiple tasks simultaneously.

2. Git Terminology

Git has its own set of terms that may be unfamiliar to those who are just starting to use this tool. Understanding this vocabulary is essential for effectively using Git, both when interacting with the tool and when collaborating with other developers.

2.1 Key Terms

In this chapter, we provide a glossary of the most commonly used terms in Git, along with brief descriptions to help you become familiar with them. The goal is for this section to be useful for explaining concepts as well as serving as a reference for future use.

  • Repository: A repository is a space where the entire history of a project is stored. It can be on your local machine or on a remote server like GitHub or GitLab. It is the core of any Git project, where all commits, branches, and versions are managed.

  • Commit: A commit is a snapshot of the changes in the project. Each commit saves a version of the project at a specific point in time, allowing you to revert to previous versions or track changes.

  • Branch: A branch is a parallel version of the repository. Branches allow you to work on different features or versions of the project independently without affecting the main code. The primary branch is usually called main or master.

  • Merge: The process of combining changes from one branch into another is called a merge. This is done to integrate work done in different branches, uniting the code so that all changes are in the same development line.

  • Staging Area: The staging area is an intermediate zone where changes are placed before being committed. Files must be added to the staging area using git add before they can be committed.

  • HEAD: HEAD is a pointer indicating the current reference you are working on. It usually points to the latest commit in the branch you are on.

  • Remote: A remote is a version of the repository stored on a server, such as GitHub or GitLab. Remote repositories are used to share your code with other developers or to maintain a backup copy.

  • Clone: Cloning a repository means making a copy of it on your local machine from a remote server. This allows you to work on the project without being connected to the server at all times.

  • Pull: The git pull command is used to update your local repository with the latest changes from the remote repository. It combines fetching (getting updates) and merging in one step.

  • Push: The git push command sends local commits to the remote repository. This is the process of sharing your changes with other developers or synchronizing them with a cloud version.

  • Rebase: git rebase is a technique that rewrites a branch's commit history by applying changes over another branch. It is used to maintain a cleaner, more linear commit history.

3. Git Instalation

Before we start using git

3.1 Windows Instalation

3.2 MacOS Instalation

3.3 Linux Instalation