How Git Works Under the Hood: Objects, Branches, and Commits
Understanding Git's internal mechanics helps developers use it more effectively. Git tracks changes using objects, references, and history.

Git is a distributed version control system that manages code changes and collaboration. Understanding how Git commands work internally helps developers use Git more confidently and effectively. Git tracks file changes using internal objects, references, and history. Each Git command operates on these underlying structures.
What happened
Git uses a distributed model that efficiently tracks changes using the working directory, staging area, and repository. The working directory is where you make changes, the staging area is where Git tracks changes that will go into your next commit, and the repository is where Git permanently stores all snapshots and change history.
Git's internal data structures are designed to store project data efficiently and accurately track every change made to files over time. A blob (Binary Large Object) stores the actual content of a single file in Git, identified by a SHA-1 hash of its content. Trees represent directories, pointing to blobs (files) and other trees (subdirectories), forming the hierarchical structure of the project.
Why it matters
Understanding Git's internal mechanics is crucial for efficient and effective use. It helps with troubleshooting and enables developers to use Git's features with confidence. Knowing how Git works under the hood allows developers to optimize their workflow and resolve issues more easily.
- Improved understanding of Git's features and capabilities
- Enhanced troubleshooting and issue resolution
- Optimized workflow and increased productivity
- Steep learning curve for beginners
- Requires manual configuration and maintenance
- Can be overwhelming for large and complex projects
How to think about it
When working with Git, think of it as a content-addressed storage system. Each commit object contains information about the author and the commit message, referencing a tree object that lists the files present in the directory at the time. Commits form a directed acyclic graph, and branches are pointers to commits.
FAQ
What is the purpose of the .git folder in a Git repository?+
The .git folder contains all the content needed for Git to reference a particular directory. It stores the commit history, tree objects, and blob objects.
What are the three main states that files can reside in when working with Git?+
Files can reside in one of three states: Modified, Staged, or Committed. The Modified state is when changes have been made to the file but not yet staged. The Staged state is when changes are marked to be included in the next commit. The Committed state is when changes are safely stored in the local repository.
What is a blob object in Git, and how is it used?+
A blob object stores the actual content of a single file in Git, identified by a SHA-1 hash of its content. It helps Git avoid duplicate storage and save space.
- engineering·3 min readPrefer Duplication Over Wrong Abstraction
Duplication is far cheaper than wrong abstraction
- engineering·3 min readJohn Carmack Discusses Fabrice Bellard's Work
John Carmack on Fabrice Bellard's projects
- engineering·3 min readIrish datacenters now guzzle 23% of the country's electricity
Ireland's datacenters consumed 23% of the country's electricity in 2025, rising 10% from 2024 despite restrictions on new grid connections.
The week’s highest-signal tech and AI stories, synthesized into a five-minute read. One email a week, no spam, unsubscribe anytime.