The Git Object types
Oct 29, 2025 at 23:07 pm
From the Git Internals docs:
Git is a content-addressable filesystem. Great. What does that mean? It means that at the core of Git is a simple key-value data store. What this means is that you can insert any kind of content into a Git repository, for which Git will hand you back a unique key you can use later to retrieve that content.
So, simply put, git stores the contents of the repository, and uses SHA-1 values as references to retrieve them (and much more).
The Four Object Types in Git
There are only four object types in Git:
- Blob - to store contents of a file.
- Tree - to store directories or other trees
- Commit - snapshot of some blobs + trees, with metadata - author, committer, message, etc.
- Tag - much like named reference to another Git object (mostly commits).
For storing any content (value), git uses zlib library to compress the content, then returns a SHA-1 code as a reference (key) to retrieve the content later.
Fun Fact: When a git repository is initalized using git init, git creates a directory named .git which is the Git directory (datastore). You can always find these objects, under the .git folder in any of your Git repositories.
How Git Stores Data
If we observe the figure above, to the left we can see the directories and files in our project - a basic todo-app server, and to the right we can see how Git stores these contents in the Git Directory as blobs, trees, commits and tags.
HEAD acts as the pointer to the current commit, as Git stores the data in the form of direct acyclic graph of the git objects, so using the HEAD, we can traverse through the graph and retrieve the working directory of any commit.
The Git Object Graph
Observe how Git stores all the data in files within the .git directory can be used to create
a direct acyclic graph like shown for the todo-app. Also note, how Git here doesn't care about the content of each blob, or tree or commit, it just needs the SHA-1 value to traverse through the graph.
The Git documentation, provides a good explanation via commands to see through how objects are stored, retrieved and used in Git.
Read more about the Git Internals:
- Git Internals - official Git docs
- Git Internals - Scott Chacon - book to easily understand the internals of Git.