Systems / Git

Build a real commit, byte by byte.

~5 minutesYou have run git commit beforeFree to explore

BY THE END, YOU CANExplain what Git stores when you commit, and why branching is almost free.

01 / Try the idea

Type anything into the file. These are the object IDs Git would store — run the command underneath to check them against Git on your own machine.

6 bytes → hashed as blob 6\0…

blob — the contentshashing…
tree — the filenamehashing…
commit — tree + author + messagehashing…
.git/refs/heads/main…

Verify the blob yourself: printf "hello\n" | git hash-object --stdin

02 / Check your understanding

You commit the same unchanged file on two branches. How many blob objects does Git store?

Read the idea in plain text

The file containing `hello\n` is six bytes. Git hashes the string `blob 6\0hello\n` and gets ce013625030ba8dba906f756967f9e9ca394464a. A tree naming that blob as greeting.txt hashes to 57e9529754dc514a3ec10db2ff882018fbe1fcbf, and a commit pointing at that tree, authored by Ada at a fixed timestamp, hashes to c53d2a0d16c66822039d159da9ef98d92f676f9d. The branch file then holds those 40 characters and a newline: 41 bytes. Change one character of the file and every one of those three IDs changes.

This is a small teaching model. Use it to reason about a design, then check the details against your own system.

Build a real commit, byte by byte.

MockStruct / Quick Learn · 31 October 2026

https://mockstruct.com/learn/git-objects

Your one-minute recap

  1. Every object is named by the SHA-1 of its own type, length and contents.
  2. Identical content is stored once, so a branch copies nothing.
  3. A branch is one file holding a 40-character object ID and a newline.

Primary source: https://git-scm.com/book/en/v2/Git-Internals-Git-References

03 / Connect the dots

See the engineering behind the idea.

Read the full explainer →
Next lesson →

Built from Git: Pro Git — Git Internals: Git References (read 31 October 2026). Original MockStruct teaching model; no affiliation. Report a correction.