Introduction to Git Internals
Git is fundamentally a content-addressable file system. In this chapter, we will explore the .git directory structure to see exactly how Git tracks the state of your project.
The .git Directory
When you run git init, Git creates a .git folder in your project root. Let’s look inside:
$ ls -al .git
HEAD
config
description
hooks/
info/
objects/
refs/
Purpose of Core Files
- HEAD: A ref pointing to your current branch.
- config: Repository-specific configuration options.
- objects: Where Git stores its primary database—commits, trees, blobs, and tags.
- refs: Pointers to commit objects (branches, tags, remotes).
What Happens When You Commit
Every commit is essentially a snapshot of your tree structure at that specific moment in time. We’ll explore this deeply in the next chapters!