Git behind the scenes
T'Chaka Dev· 7 pages· 5 min read
Git is not magic. It is a content-addressed key-value store with a clever naming scheme on top.
The .git folder
Everything git knows lives in one directory:
bash
ls -a .git
Delete it and you have an ordinary folder again — with every checkpoint gone.
Objects
Git stores three kinds of thing: blobs (file contents), trees (directory listings), and commits (a tree plus metadata plus a parent).
DIAGRAM blob, tree, and commit as three nested boxes, each labeled with a hash
Each is named by the SHA-1 hash of its contents, which is why the same file stored twice costs nothing.
HEAD
HEAD is a pointer to where you currently stand in history. Almost every confusing git message is really telling you that HEAD is not where you thought.
bash
cat .git/HEAD