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.