Git is a distributed version control system. At the heart of Git’s powerful capabilities lies its object model. Understanding Git’s object model is important for mastering its use and leveraging its full potential. This article will dive deep into the components of the Git object model, explaining how each part functions and contributes to the system’s efficiency.
When we work with git, the first command that we use to initialize our repository to git repository is the git init command. After using this command, we can see that the .git folder is created. Let’s get deep dive into the folder and see what all we have got in the .git folder.

Git, a distributed version control system, has revolutionized how developers manage and track changes in their projects. At the heart of Git’s powerful capabilities lies its object model. Understanding Git’s object model is crucial for mastering its use and leveraging its full potential. This article will dive deep into the components of the Git object model, explaining how each part functions and contributes to the system’s efficiency.
We can see that we have many subdirectories in the .git folder, but the subdirectory that we would have a look at is the .git/objects subdirectory. Generally, the objects folder consists of four different types of objects – blob, tree, commit and tag.Â
.git/objects directory is empty as of now but we will see some changes in it and we will understand why this directory is important to us. In Git, every commit, every tree, and every file is saved in the objects folder as a hash value. There is a unique hash value for every object which helps Git to where it is located. The folders are created accordingly. We will learn about hashes as we move forward. Since the objects folder is empty as of now, let’s create a file demo.txt and write “Hello Geeks” in it.
We are using Ubuntu here but Windows users can work with the git bash . Ubuntu Commands can be run on git bash.

Now, let’s add our changes to the staging area and commit our changes by using –Â
git add demo.txtÂ
git commit -m “First Commit”

Let us observe changes in our objects folder after this command.

So we got new directories which are named 2 characters long and have 38 characters long file name.
Note: You might have different hashes in your computers so no need to worry if you don’t get the same hashes.
Git generates a 40-character checksum (SHA-1) hash for every object and the first two characters of that checksum are used as the directory name and the other 38 as a file name.
Therefore the 40 character hashes that we have are –
6d510f79378ca9954e1078a70ff4fdaaa64494fe
7c5d8f39237365acdf66527189ba4fbb6c59b4fc
893f819f4a3b12c76aec907ad636edff48ffcfad
Let us now check what are these 3 different objects and their types. We will use the command – git cat-fileÂ

However , the command that we would be needing are –Â
- git cat-file -t <hash value> Â // used for showing type of object
- git cat-file -p <hash-value> // used for showing content of object
Let us check the type of our objects –Â
git cat-file -t <40 character hash value> Â //checks the type of the object

So, the types that we have got are – blob, tree, and commit. Let us understand them in more detail.
1. Blob Object
Blob – Binary Large Object
Blob stores the contents of the file. Whenever we commit our files the first type of objects that are created are the blob objects. Let us have a look at the content of our blob object with the help of –
git cat-file -p <blob object hash value>Â

We can see that we got the content of our file demo.txt that we wrote initially i.e Hello Geeks.
2. Tree Object
Tree objects contain a list of all files in our repository with a pointer to the blob object assigned to them. Let us have a look at the content of our tree object with the help of –
git cat-file -p <tree object hash value>Â

Each line in a Tree object has – file permissions, object type, object hash, and filename. Let us break down the line –Â
File Permission (100644) – Permissions of 644 means that the owner of the file has read and write access, while the other users on the system only have read access. blob represents the type of object. 40 character hash represents the hash of the object. You can verify it with your blob hash. demo.txt represents the filename.
3. Commit Object
Git creates a commit object that has a pointer to its tree object. The commit object contains – tree object hash, parent commit hash, author, committer, date, and message. Let us have a look at the content of our commit object with the help of –
git logÂ
git cat-file -p <commit object hash value>Â

As clear from the above image, the commit object consists of – Tree object, Name of the author, Name of the committer, and the commit message. Since we have covered 3 different types of objects, we are left with one i.e Tag Object.
4. Tag Object
A tag object contains an object name, object type, tag name, the name of the person who created the tag, and a message. Let us make an annotated tag using –Â
git tag -a “first-tag” -m “Tag For First Commit”Â

Let us now check our objects folder to see whether the tag object is created or not.

We can see that a new directory “97” is being added. Let us now verify our type and see the contents of our tag object.
git cat-file -t <tag object hash value>
git cat-file -p <tag object hash value>

We can see that the tag object is pointing to the commit object (verify using our commit hash value) as we expected. I hope you would have found this article useful. We have covered all four object types and you can try more by doing some changes and repeating above the steps again.
Similar Reads
Object Model in Java
The object model is a system or interface which is basically used to visualize elements in terms of objects in a software application. It is modeled using object-oriented techniques and before any programming or development is done, the object model is used to create a system model or an architectur
8 min read
Git Security Model
Git is one of the most popular version control systems, used by developers and non-developers for tracking changes, collaborating on projects, and managing codebases. While Git is popular for its efficiency in handling version control, its security features are equally robust, ensuring that your cod
7 min read
Models in OOAD
While creating software, imagine using blueprints to design a house that's what models do in Object Oriented Analysis and Design (OOAD). Just like blueprints help us understand how a house will be built, models in OOAD help developers visualize and plan out software before they start coding. These m
8 min read
Git Introduction
Git is a powerful and widely used version control system that helps developers track changes in their code, collaborate with others, and manage project history effectively. Whether you are a professional developer or just starting out, understanding Git is important for modern software development.
6 min read
Objects in Javascript
An object in JavaScript is a data structure used to store related data collections. It stores data as key-value pairs, where each key is a unique identifier for the associated value. Objects are dynamic, which means the properties can be added, modified, or deleted at runtime. There are two primary
4 min read
Git - Pack Objects: A Comprehensive Guide
Git is a powerful tool for managing code, and one of the ways it stays fast and efficient is by using pack objects. These help Git store and transfer data in a compressed way, saving space and improving performance. In the below article, you will learn what pack objects are, why they matter, and how
5 min read
Git - Index
In Git, the index, also known as the staging area, plays an important role in the version control process. It acts as an intermediary between your working directory and the repository, allowing you to prepare and review changes before committing them. This article explores the concept of the Git ind
3 min read
Domain Model Refinement in OOAD
Object-Oriented Analysis and Design (OOAD) is the most important aspect of creating robust and maintainable software. The creation of a reliable domain model is a crucial stage in this procedure. This model serves as a blueprint, outlining the key ideas and connections in the problem domain that the
8 min read
Git - Rename
Renaming the file is very important when we are working on a project. Git Rename is used to rename a file in the working directory. Suppose we are working in a team and any fellow developer created the file and we want to rename it using Git or Github so this command help us to do so. We may change
2 min read
Git Cheat Sheet
Git Cheat Sheet is a comprehensive quick guide for learning Git concepts, from very basic to advanced levels. By this Git Cheat Sheet, our aim is to provide a handy reference tool for both beginners and experienced developers/DevOps engineers. This Git Cheat Sheet not only makes it easier for newcom
10 min read