Learn to Code
All tracks
Learn to Code

Free lessons from scratch to pro — every language, databases and DevOps.

AboutContactPrivacy PolicyTerms of Use

Your progress is saved in this browser. © 2026 Learn to Code

GIT
Git & GitHub
0/10 completed
Beginner
What is version control?Your first commitsBranchesGitHub and remotes
Intermediate
Merging and conflictsUndoing changesPull requests and code reviewRebasing
Advanced
Git internals
Pro
Git workflows for teams
Tracks / Git & GitHub / Beginner

What is version control?

Have you ever had files like these?

report.docx
report_final.docx
report_final_v2.docx
report_final_v2_REALLY_FINAL.docx

Version control solves this properly. It records every change to your files over time, so you can see what changed, who changed it, when and why, and go back to any earlier version.

Git is by far the most popular version control system: almost every software company and open-source project uses it.

What Git gives you

  • Unlimited undo. Return to any saved point in your project's history.
  • Experiment safely. Try ideas on a separate branch without breaking working code.
  • Collaboration. Many people work on the same code at once, and Git merges their work.
  • History and blame. Find exactly which change introduced a bug.
  • Backup. Every copy of a Git repository contains the full history.

Git vs GitHub

Git GitHub (or GitLab, Bitbucket)
A tool installed on your computer A website that hosts Git repositories
Works fully offline Adds collaboration: pull requests, issues, code review, CI
Created by Linus Torvalds (2005) for Linux Owned by Microsoft (2018)

You can use Git without GitHub, but you can't use GitHub without Git.

The three areas

This is the most important idea in Git:

  Working directory  ──git add──▶  Staging area  ──git commit──▶  Repository
  (your files as you              (changes you've                (permanent
   edit them)                      chosen for the next             history of
                                   snapshot)                       snapshots)
  1. Working directory: the files you're editing right now.
  2. Staging area (also called the "index"): a draft of your next snapshot. You choose exactly which changes go in.
  3. Repository: saved snapshots, called commits, stored in a hidden .git folder.

A commit is a snapshot of your whole project at a moment in time, with a message describing it.

Try it: the built-in Git terminal

Below is a Git simulator. Press ▶ Run to execute the commands, then keep typing your own commands in the terminal. The commit graph under it draws your history as you go.

Git terminal (simulator) · editable

Read the output of each command carefully:

  • After echo, hello.txt is untracked: Git sees it but isn't saving it.
  • After git add, it's staged: "Changes to be committed".
  • After git commit, it's saved permanently in history.

The simulator supports the most common Git commands plus a mini shell (ls, cat, echo "text" > file). Type help in it to see everything. For the real thing, install Git (below) and use your own terminal.

Installing real Git

  • Mac: run git --version in Terminal; macOS offers to install it. Or use brew install git.
  • Windows: install Git for Windows from git-scm.com. It includes "Git Bash".
  • Linux: sudo apt install git or sudo dnf install git.

Then tell Git who you are. This is recorded in every commit:

bash
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main
git --version
✎ Check your understanding

1.What is the staging area for?

2.What's the difference between Git and GitHub?