A lot of its design decisions are based around the data storage model, and tooling built to operate on those data structures. I recall a good write-up from a decade gone now, but no dice googling for it. The short version is probably:
- Everything is a blob, a text file named after the SHA1 of its content.
- Files are just themselves.
- Directories list <entry sha1> <name> for their entries (file or subdirectory).
- Commits list a Directory (the project root), and some metadata about the commit like the author, commit message, and the parent(s) of the commit.
- A branch then is just an end-user-named reference to a commit's hash.
Everything flows from that - SHAs are reused, if you're doing a diff and two directory entries have the same sha referencing a file, there's no change. Switching a branch is modifying the special HEAD branch content, and recursively walking it to rehydrate the filesystem (and comparing to the previous checkout to optimize, skipping whole directories that don't change).
- Everything is a blob, a text file named after the SHA1 of its content.
- Files are just themselves.
- Directories list <entry sha1> <name> for their entries (file or subdirectory).
- Commits list a Directory (the project root), and some metadata about the commit like the author, commit message, and the parent(s) of the commit.
- A branch then is just an end-user-named reference to a commit's hash.
Everything flows from that - SHAs are reused, if you're doing a diff and two directory entries have the same sha referencing a file, there's no change. Switching a branch is modifying the special HEAD branch content, and recursively walking it to rehydrate the filesystem (and comparing to the previous checkout to optimize, skipping whole directories that don't change).