← Git

Git Fundamentals

What is Git and what is it for?

Show answer — try answering out loud first

Git is a distributed version control system: it records the change history of a project so you can go back to any previous version, work in parallel with other people, and merge work without stepping on each other. It's distributed because each person has a complete copy of the repository on their machine.

Imagine you're writing a project and you save copies: proyecto_final, proyecto_final_v2, proyecto_final_bueno_este_si. That's version control by hand, and it's a mess.

Git does that for you, but properly:

  • It saves a snapshot (commit) of your project every time you ask it to.
  • You can go back to any previous snapshot.
  • You can work on several ideas at once with branches, without breaking what already works.
  • Several people can work on the same project and merge their changes.

Being distributed means you don't depend on a central server to work: everyone has the complete history on their computer and can make commits without internet.

# Check the installed Git version (confirm you have it)
git --version
# Expected output: git version 2.x.x

# Turn any folder into a Git repository
git init
# Output: Initialized empty Git repository in /ruta/.git/

# Check the repository status
git status
# Shows which branch you're on and which files have changed

Confusing Git with GitHub, or thinking that Git needs internet to work. Git is a tool that runs on your machine and works offline; GitHub is a cloud service for hosting Git repositories. Another mistake: believing that Git stores "differences" when it actually stores snapshots of the project at each commit.

"Git is a distributed version control system. It's used to track the change history of a project, be able to go back, work in parallel with branches, and collaborate with other people by merging their work. It's distributed because everyone has the complete repository locally, so I can make commits offline and then sync with a remote."

Quick challenge

What is the difference between a centralized version control system and a distributed one like Git?

Show answer

In a centralized system (like SVN), the history lives on a single server and you need a connection for almost everything. In a distributed one like Git, each person has a complete copy of the repository (with the entire history) on their machine, so they can work and make commits offline, and only sync with the remote when they want.