Inside Git
The object database: blobs and hashes, trees and commits, and refs, HEAD and revision expressions.
About 4 hours of study
Learning objectives
- Compute blob, tree and commit ids
- Read commit objects
- Resolve refs and revision expressions
Lessons
- 1
Inside Git: objects and hashes Intermediate
Git is a content-addressed store: every file version is saved as a blob named by the SHA-1 hash of its contents. Compute blob ids exactly as Git does, see why identical files are stored once, and use short hashes safely.
- 2
Inside Git: trees and commits Intermediate
See how Git builds a snapshot from objects: trees list names and point to blobs and subtrees, and commits point to a tree, their parents, an author and a message. Compute tree and commit ids and see why history cannot be changed silently.
- 3
Branches, HEAD and revision names Intermediate
Branches are just names pointing at commits, and HEAD says which one you are on. Learn how refs are stored, what a detached HEAD is, which branches contain a commit, and how to name commits with expressions such as HEAD~2 and main^2.
Module practice
- Git: Compute a blob idEasy
- Git: The shortest unique abbreviationMedium
- Git: Compute a tree idHard
- Git: Read a commit objectEasy
- Git: Compute a commit idMedium
- Git: Walk the historyHard
- Git: Where does HEAD point?Easy
- Git: Which branches contain a commit?Medium
- Git: Resolve revision expressionsHard