Inside Git

The object database: blobs and hashes, trees and commits, and refs, HEAD and revision expressions.

About 4 hours of study

Learning objectives

Lessons

  1. 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. 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. 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

Module quiz

1. What does a blob store?
2. What is a branch in Git?
3. Two files have identical contents. How many blobs are stored?
4. What is HEAD~2?
5. What does a detached HEAD mean?
6. Why does changing an old file version change every later commit id?

‹ Getting startedBranching and merging ›