sn sysnerdunderstand it from the kernel up
← curriculum map
Git
Tool · ~40 min · 4 labs
map / The stack / Git
The stack Tool ~40 min requires: Linux

Git

Git isn't a pile of commands, it's four object types and a graph. Learn the model with plumbing and the porcelain (merge, rebase, reset) stops being frightening.

Q1Content is addressed by its hashwarm-up

Git stores content as blobs, named by the SHA of the content itself. Same bytes → same hash, always.

Task

Hash a string two different ways and compare.

Verify it yourself
verify
$ echo hi | git hash-object --stdin

Write the same content to a file and git hash-object it — identical hash. Content-addressing, first-hand.

Reveal solution
solution
$ git init demo && cd demo
$ echo hi | git hash-object --stdin
$ printf hi | git hash-object --stdin -   # note: differs, trailing newline matters
Q2A commit is a hash of a treecore

Staging builds a tree (a directory snapshot); a commit is a tiny object pointing at one tree plus parent + author.

Task

Stage a file, write the tree, and read it back.

Verify it yourself
verify
$ git cat-file -p $(git write-tree)

The tree lists your file as a blob. A commit is just this tree, wrapped with metadata.

Reveal solution
solution
$ echo hello > f
$ git add f
$ git write-tree
$ git cat-file -p $(git write-tree)
Q3Branches are just pointerscore

A branch is a 41-byte file holding one commit SHA. "Switching branches" moves a pointer — nothing is copied.

Task

Commit, branch, and prove both refs point at the same commit.

Verify it yourself
verify
$ cat .git/refs/heads/main .git/refs/heads/feature

Both files contain the same SHA. That's all a branch is.

Reveal solution
solution
$ git commit -m first
$ git branch feature
$ cat .git/refs/heads/main
$ cat .git/refs/heads/feature
Sponsored

Reach engineers who read the man page

Native, contextual, no tracking — this is how the curriculum stays free.

Q4Break-and-fix — recover a "lost" commitdebug

A hard reset seems to destroy work. It doesn't — the commit is still in the object store, and the reflog remembers where HEAD has been.

Task

Make a commit, hard-reset past it, then bring it back.

Verify it yourself
verify
$ git log --oneline -1

After reset --hard to the reflog SHA, your "lost" commit is back at the tip. The reflog is your safety net.

Reveal solution
solution
$ echo more >> f && git commit -am second
$ git reset --hard HEAD~1   # "lose" it
$ git reflog                 # find the second commit's SHA
$ git reset --hard <sha-of-second>
What you just built

Blobs, trees, commits, refs — plus the reflog. Once you see Git as objects in a graph, rebases and merges are just re-pointing the graph, and you can always recover. This model is the foundation for GitHub Actions and GitOps.