Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

โ€œInvest in yourself โ€” your confidence is always worth it.โ€

Explore Cosmetic Hospitals

Start your journey today โ€” compare options in one place.

Git Tutorial: Types of git objects


If you have read Curious git, you know that git stores different types of objects in .git/objects. The object types are:

commit;
tree;
blob;
annotated tag.
Here we make examples of each of these object types in a new repository.

First we make the working tree and initialize the repository:

$ mkdir example_repo
$ cd example_repo
$ git init
Initialized empty Git repository in /Users/mb312/dev_trees/curious-git/working/example_repo/.git/
Next we make an example commit:

$ echo "An example file" > example_file.txt
$ git add example_file.txt
$ git commit -m "An example commit"
[master (root-commit) cf1fdb2] An example commit
 1 file changed, 1 insertion(+)
 create mode 100644 example_file.txt
From Curious git, we expect there will now be three objects in the directory .git/objects, one storing the backup of example_file.txt, one storing the directory listing for the commit, and one storing the commit message:

objects
โ”œโ”€โ”€ 2f
โ”‚   โ””โ”€โ”€ 781156939ad540b2434d012446154321e41e03 [32B]
โ”œโ”€โ”€ 83
โ”‚   โ””โ”€โ”€ 207f0274383b4a79ff6d6c297e95204ba961bc [60B]
โ”œโ”€โ”€ cf
โ”‚   โ””โ”€โ”€ 1fdb215f948795523cde2987107944d1374777 [135B]
โ”œโ”€โ”€ info
โ””โ”€โ”€ pack
Commit object type
The commit object contains the directory tree object hash, parent commit hash, author, committer, date and message.

Git log will show us the hash for the commit message:

$ git log
commit cf1fdb215f948795523cde2987107944d1374777
Author: Matthew Brett 
Date:   Mon Feb 13 16:56:24 2017 +0000

    An example commit
Note
I'll use git cat-file to show the contents of the hashed files in .git/objects, but cat-file is a relatively obscure git command that you will probably not need in your daily git work.

git cat-file -t shows us the type of the object represented by a particular hash:

$ git cat-file -t cf1fdb215f948795523cde2987107944d1374777
commit
git cat-file -p shows the contents of the file associated with this hash:

$ git cat-file -p cf1fdb215f948795523cde2987107944d1374777
tree 83207f0274383b4a79ff6d6c297e95204ba961bc
author Matthew Brett  1487004984 +0000
committer Matthew Brett  1487004984 +0000

An example commit
Tree object type
The commit contents gave us the hash of the directory listing for the commit. If we inspect this object, we find it is of type โ€œtreeโ€ and contains the directory listing for the commit:

$ git cat-file -t 83207f0274383b4a79ff6d6c297e95204ba961bc
tree

$ git cat-file -p 83207f0274383b4a79ff6d6c297e95204ba961bc
100644 blob 2f781156939ad540b2434d012446154321e41e03	example_file.txt
The tree object contains one line per file or subdirectory, with each line giving file permissions, object type, object hash and filename. Object type is usually one of "blob" for a file or "tree" for a subdirectory [1].

Blob object type
The directory listing gave us the hash of the stored of example_file.txt. This object is of type โ€œblobโ€ and contains the file snapshot:

$ git cat-file -t 2f781156939ad540b2434d012446154321e41e03
blob

$ git cat-file -p 2f781156939ad540b2434d012446154321e41e03
An example file
Blob is an abbreviation for โ€œbinary large objectโ€. When we git add a file such as example_file.txt, git creates a blob object containing the contents of the file. Blobs are therefore the git object type for storing files.

Tag object type
There is also a git type for annotated tags. We donโ€™t have one of those yet, so letโ€™s make one:

$ git tag -a first-commit -m "Tag pointing to first commit"
This gives us a new object in .git/objects:

objects
โ”œโ”€โ”€ 2f
โ”‚   โ””โ”€โ”€ 781156939ad540b2434d012446154321e41e03 [32B]
โ”œโ”€โ”€ 83
โ”‚   โ””โ”€โ”€ 207f0274383b4a79ff6d6c297e95204ba961bc [60B]
โ”œโ”€โ”€ c7
โ”‚   โ””โ”€โ”€ e94cc3a0d893a23dab7bb2f601dc8e682a42cc [146B]
โ”œโ”€โ”€ cf
โ”‚   โ””โ”€โ”€ 1fdb215f948795523cde2987107944d1374777 [135B]
โ”œโ”€โ”€ info
โ””โ”€โ”€ pack
The object is of type "tag":

$ git cat-file -t c7e94cc3a0d893a23dab7bb2f601dc8e682a42cc
tag
The tag object type contains the hash of the tagged object, the type of tagged object (usually a commit), the tag name, author, date and message:

$ git cat-file -p c7e94cc3a0d893a23dab7bb2f601dc8e682a42cc
object cf1fdb215f948795523cde2987107944d1374777
type commit
tag first-commit
tagger Matthew Brett  1487004984 +0000

Tag pointing to first commit
Notice that the "object" the tag points to, via its hash, is the commit object, as we were expecting.Code language: PHP (php)

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Top 10 AI SEO Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, AI SEO tools have become indispensable for digital marketers, businesses, and content creators aiming to dominate search engine rankings. These tools leverage artificial intelligence…

Read More

Top 10 Product Lifecycle Management (PLM) Tools in 2026: Features, Pros, Cons & Comparison

Introduction Product Lifecycle Management (PLM) is a strategic approach to managing a productโ€™s journey from conception through design, manufacturing, and end-of-life. In 2026, PLM software has evolved…

Read More

Top 10 Patch Management Tools in 2026: Features, Pros, Cons & Comparison

Introduction: The Importance of Patch Management in 2026 In 2026, as cyber threats evolve and technology becomes more complex, patch management tools are critical for maintaining cybersecurity…

Read More

Top 10 Headless CMS Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, Headless Content Management Systems (CMS) have become the go-to solution for businesses seeking flexibility, scalability, and a modern approach to content management. Unlike traditional…

Read More

Top 10 AI Lead Scoring Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, AI lead scoring tools have become indispensable for B2B and B2C businesses aiming to optimize their sales pipelines. These tools leverage artificial intelligence to…

Read More

Top 10 AI Portfolio Optimization Tools in 2026: Features, Pros, Cons & Comparison

Introduction Investment management has always been about making smart choices at the right time. Traditionally, this required endless hours of research, manual calculations, and intuition. But in…

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Jason Mitchell
Jason Mitchell
1 month ago

Good overview of Gitโ€™s core object types (blob, tree, commit, tag). One practical point worth adding is how these objects behave in real repositories after operations like garbage collection and packingโ€”objects donโ€™t always exist as loose files, so debugging at scale often requires understanding packfiles and git verify-pack rather than just the object types themselves. This becomes especially relevant in CI/CD or large monorepos where storage and performance optimizations change how these objects are actually stored and accessed.

1
0
Would love your thoughts, please comment.x
()
x