Skip to content
BIASED

Git: the object model and workflows

Block 1 of 6~3 min

Objects: blobs, trees and commits

Every build in the rest of this course starts from an exact version of source files. Git keeps that history as a small regular data structure: a store of immutable objects named by their hashes, linked into a graph, with movable names pointing into it.

Under .git/objects the value is an object; the key is a hash of its type, size and content. Three kinds matter:

  • a blob — the bytes of one file, with no name and no permissions;
  • a tree — one directory: mode, type, hash and name per entry;
  • a commit — hash of a root tree, zero or more parent commits, author, committer, timestamps and a message.

Worked example. After git add of README.md (Shop service\n, 13 bytes) and src/app.py, two blobs exist. The README name is the SHA-1 of blob 13\0 plus the content — the same digest shasum computes. A commit writes trees and a commit object. A second commit that changes only app.py adds one blob, two trees and one commit; the README blob is shared. git count-objects reports 9 objects.

Answers are saved on the server and tied to this browser until you sign in.

Go deeper — optional

Code and labs do not count toward the main percentage or the certificate.

  • Object model: blob/tree/commitoptional

    From hashes rebuild commit→tree→blobs; explain why a rename is delete+add of content.

    ~20 min · easier on a computer · The matching course topic has been read.

    Self-check in the notebook — not part of mastery or the certificate.