Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 05 · From Scratch · Git · with code: Go · about 12 min to read

Play it as a journeyTutor comes with a plan

Build Your Own Git

What Git Actually Ships
What Git Actually Ships · Open board

The nearest board the site has: it follows what git does with two versions of a file once they exist. This build goes one level underneath it, to how a version is stored at all.

Before you start. This series builds a small copy of git, the tool that keeps every saved version of a folder of files. You need one idea, refreshed here: a hash is a fingerprint computed from every byte of a thing, so the same bytes always give the same fingerprint and one changed byte gives a different one (the hashing lesson draws it). If Go is new to you, Enough Go to read these builds is an optional read first. The user-side story of git, branches and merges, is Git: the ledger every change signs (commits, branches, merge and rebase). This build is the machinery under that lesson.

Code: teaching/code/from-scratch/git/. One Go module, five stages, each stage a program you can run: go run ./01-blob up to go run ./05-checkout. Each stage folder holds every file the stage before it needed plus one new file, so the last stage is the whole tool. No git library, and no call to the git program: the only place real git appears is in the proofs, where it reads what this build wrote.

Lesson 32 of 117 in From Scratch

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 7 April 2005: the first commit explains itself
  • What is a version? A snapshot with a name
  • A folder is a list of names and fingerprints: the tree
  • A commit is a tree plus a past
  • The five stages
  • What this build leaves out, on purpose
  • Go, as you go

Terms it explains: blob, tree, commit, snapshot, ref, HEAD, index.

Review From Scratch