All tutorials

Course 02 · Git

How Git growsa history

Git becomes much easier when you stop imagining folders being copied and start seeing snapshots connected into a tree. This guide makes that tree visible.

Beginner 18 min 5 experiments No prerequisites
01 · A map before the commands

Learn one picture in five moves.

We will start with the value Git gives you, then reveal the machinery only when it answers a useful question. Every later concept is a small change to the same commit tree.

The destination: look at a graph and predict what a command will move.

  1. 01
    Save meaningful checkpointsWhy history is more useful than files named final-final-2.
    why
  2. 02
    Move changes through three placesWorking tree → staging area → repository.
    local
  3. 03
    Grow more than one futureBranches are movable labels, not copied projects.
    branch
  4. 04
    Combine those futuresMerge preserves the fork; rebase redraws one side.
    history
  5. 05
    Exchange history with other repositoriesFetch, integrate, and push without confusing local and remote.
    share
02 · Why Git is useful

Git lets a project have memory—and parallel futures.

A commit gives a change a durable name and context. A branch lets you try an idea without disturbing another line of work. A remote lets several people exchange those histories.

The real payoff is not merely “backup.” It is the freedom to experiment, compare, explain, review, and recover.

RecoverReturn to a known checkpoint.
ExperimentGrow an idea on its own branch.
ExplainRecord why each coherent change exists.
CollaborateExchange histories and review differences.
03 · Move one change

Git gives a change three local places to be.

Edit a file, choose it for the next snapshot, then commit that snapshot to history. The staging area is the deliberate boundary between “everything I changed” and “the change I mean to record.”

Use the controls in order.

One file, three places
Clean repository
01
Working treeThe files you can edit
JS
app.jsmatches commit A
clean
02
Staging areaThe proposed next snapshot

Nothing selected yet.

03
RepositoryCommitted snapshots
A
Initial interfacemain · HEAD
$ git status

Nothing to commit. Your working tree matches commit A.

04 · Read the graph

A commit is a snapshot with a parent.

Most commits point to one earlier commit. Follow those parent links and you get history. The long hexadecimal commit ID is Git's permanent name for that snapshot.

A branch such as main is only a movable label pointing at one commit. HEAD tells Git which branch—or occasionally which commit—you currently have checked out.

Three commits on the main branchCommit C points to B, which points to A. The main branch points to C, and HEAD points to main.ABCmainHEADa18f…c03b…e71d…

Commit C stores a project snapshot, metadata, and the identity of parent B.

The idea to keep
Git stores snapshots. Parent links make history. Branches and HEAD are labels that move.