Git & GitHub · Lesson 107 of 144
Following the Pointers
Trees and blobs.
Let's follow the pointers from a commit, all the way down to a file's contents. Every object is named by its hash.

- From commit
- To tree
- To blob
From tree to blob
Cat file on the commit's tree, using head, a caret, and curly braces with the word tree. It lists our three files, each with the hash of its blob. Now cat file on the index dot HTML blob. There's the file's content, exactly as committed.
git
git cat-file -p "HEAD^{tree}" 100644 blob 058b39baaca23d0c9c5cf8c9f2e0ef8c351e460c about.html 100644 blob 93dd595b334c23932a183a8a4b3e98bdad2c9494 index.html 100644 blob 693ce9b84057d37872139150e32284abbbe76754 style.css git cat-file -p 93dd595 <h1>My Site</h1> <p>Welcome!</p> <a href="about.html">About</a>
Why this is clever
Because objects are named by their content, two identical files are stored only once. A commit that changes one file reuses all the other blobs from before. That's why commits are fast, and history takes so little space, even after thousands of commits.
Named by contentthe hash
Identical filesstored once
New commitreuses old blobs
Resultfast and small
Summary
Commits point to trees, trees point to blobs, and identical content is stored once. Next, what a branch really is.
Key takeaways- git cat-file -p
- Objects named by hash
- Shared, not copied
Next up: What a Branch Really Is — a file with a hash