Boss lesson · Unit 01
Inside .git
Blobs, trees and commits, named by their content
What you practise
- Blobs, trees and commits, content-addressed by hash
git hash-objectandgit cat-file -pto walk from a commit to a file- Why identical files are stored once and history can't change silently
Try a question from this lesson
Pick one
Two files hold exactly the same text. The last line counts the objects git has stored after git add. What does it print?
git init -q
echo same > a.txt
echo same > b.txt
git add .
find .git/objects -type f | wc -lCorrect answer
1
Why
Git files content under a name computed from the content itself: its hash. Same bytes, same hash, so one object serves both files. Note that git add stored it. Nothing has been committed yet.
The idea
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
Three kinds of object
Everything git stores is an object, named by the hash of its content.
A blob is the bytes of one file, with no name attached. A tree is a folder: a list of names, each pointing at a blob or at another tree. A commit points at one tree (the snapshot) and at its parent commits.
commit ---> tree ---> blob (a.txt)
| \-----> blob (b.txt)
v
parent commit11 more exercises in the app
- 4× type the answer
- 3× multiple choice
- 1× fill the blanks
- 1× true or false
- 1× order the lines
- 1× match the pairs
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.