Warm-up · from “Hashing and blob objects”
Does a blob store its filename?
Does a blob store its filename?
No notes: write what you remember, then check. Recalling before reading is what makes it stick.
The problem
A blob knows nothing about filenames. How can Git reconstruct a folder with an executable file and two identical text files?
After this lesson you can
Read tree entries.
Explain nested directories and file modes.
Identify why normal Git ignores empty directories.
Key terms
Full glossarySay what each term means, then open it to check.
Tree · new in this lesson
Directory snapshot mapping names, modes and object IDs.
Object ID · from lesson 5
Hash-based identity of a serialized Git object.
Blob · from lesson 5
Object storing file contents without a filename.
Commit · preview, covered in lesson 7
Object identifying a root tree, parent(s), metadata and message.
Index · preview, covered in lesson 9
Prepared path-to-object entries, plus metadata and conflict stages.
Visual mental model
- Root tree
- src subtree
- README blobREADME.md
- app.txt blobsrc/app.txt
Build the mental model
A tree maps names to object IDs and modes. Common modes are 100644 for regular files, 100755 for executable files, 120000 for symbolic links, and 040000 for subtrees; 160000 is used for gitlinks. A root tree points to entries at the root. A subtree points to its own children. The tree stores the basename at its level rather than full paths.
Computed in your browser: the tree ID depends on every entry’s mode, name and object ID.
Under the hood
The Index lists full paths and modes; git write-tree builds the corresponding tree hierarchy. Git can represent an empty tree object, but normal add/commit workflows do not track empty directories as standalone items. Use a meaningful placeholder if the empty directory must exist after checkout. Git does not preserve arbitrary Unix permission bits, ownership or modification timestamps in trees.
Common mistake · important nuance
The object type shown by ls-tree is inferred from the mode; the binary tree format stores mode, name and raw object ID.