Inside Git: How It Really Works (With the `.git` Folder Explained)

Search for a command to run...

No comments yet. Be the first to comment.
Comeing soon

In the previous blog of this JavaScript series, we explored JavaScript Operators: The Basics You Need to Know and learned how operators help us perform calculations, comparisons, and logical checks. B

In the previous blog of this JavaScript series, we learned about Variables and Data Types — how JavaScript stores information. Now the next question is: How do we actually work with those values? Th

If you're starting your JavaScript journey, one of the first concepts you'll encounter is Variables and Data Types. They are the foundation of everything in programming — from storing a user's name to

JavaScript Promises are one of the most misunderstood yet essential features in modern JavaScript development. Most articles explain the syntax. Very few explain: Why Promises exist How they actuall

Subhrangsu
18 posts
Git is not magic. Git is just a very smart storage system.
Most beginners learn Git by memorizing commands. But the moment you visualize what Git is storing and where, everything starts to click.
In this article, we’ll understand Git using real code changes, human instincts, staging, and internal storage — the same way Git actually thinks.
Look at a simple change like this:
+ const fname = 'Subhrangsu';
+ const lname = 'Bera';
- const lname = 'Bera';
const lname = '';
+ // Kuch bi karoge
In real life, code changes constantly:
👉 Where should these changes be stored safely?
Before Git existed, developers genuinely struggled with this question.
changes.txtLet’s imagine Git does not exist.
You decide to do something simple and logical.
Inside your project:
project/
├── hello.js
└── changes.txt
Every time you change code, you imagine that this file records what changed.
hello.js
const fname = "Subhrangsu";
const lname = "";
You imagine changes.txt contains:
+ const fname = 'Subhrangsu';
+ const lname = 'Bera';
- const lname = 'Bera';
const lname = '';
+ // Kuch bi karoge
Honestly? This idea is very interesting — and very human.
Now that we have a human-style solution, let’s test it against real-world development needs.
changes.txt Work in Real Projects?changes.txt may contain some code, but it only records differences.
It never stores the entire project state at a specific moment in time.
Tomorrow, if someone asks:
“What did
hello.jslook like yesterday — exactly?”
You don’t really know.
You would need to:
There is:
After a few days, entries become vague:
Fixed bug
Updated logic
Minor changes
Now the history exists… but it no longer has clear meaning.
Now imagine this:
hello.js
feature.js
config.json
All files change together.
How do you describe relationships between changes using one text file?
You can’t.
Two developers editing:
changes.txt
at the same time?
💥 conflicts 💥 confusion 💥 broken trust
Git is essentially:
An automated, perfect, unbreakable version of
changes.txt
But instead of storing descriptions or diffs, Git stores exact snapshots of your project.
And it stores everything inside one place 👇
.git/
.git Folder?When you run:
git init
Git creates a hidden, database-like folder called .git.
📌 Important truth:
.gitis the repository. Your project folder is just the working area.
Delete .git → Git history is gone.
Conceptually:
VCS (Version Control System) → Git
Git → Server Host (GitHub)
.git👉 GitHub is not Git GitHub is only a host
This is the biggest mindset shift.
Git does NOT think:
“hello.js changed”
Git thinks:
“The content inside this file changed”
That’s why Git can:
+ and -This is where Git becomes smarter than changes.txt.
hello.txt
feature.txt
You run:
git add hello.txt
.git📌 Result:
Staging allows selective snapshots.
git add hello.txt
git add feature.txt
You decide:
👉 Dropbox / Google Drive cannot do this
git commitgit commit -m "updated name variables"
Git does not store differences.
Git stores a snapshot.
Internally Git:
.git/objects📌 A commit is a snapshot, not a patch.
Git internally stores only three core object types.
console.log("Hello");
No filename. Only content.
hello.js → blob
src/ → tree
Stores:
Relationship:
Commit → Tree → Blob
Every Git object is stored using a hash:
e83c5163316f89bfbde7d9ab23ca2e25604af290
Hashes guarantee:
Change content → hash changes → Git immediately knows.
Working Directory
↓ git add
Staging Area
↓ git commit
.git (Object Store)
↓ git push
GitHub Server
This is Git in one picture.
Git is a content-addressed database with a time machine UI
.git → databasegit add → prepare snapshotgit commit → save snapshotgit push → share snapshotOnce this clicks: ❌ no command fear ❌ no confusion ✅ full confidence
You don’t need to memorize Git commands.
You need to understand:
The idea of changes.txt was never wrong.
It just needed a machine to do it perfectly.
And that machine is Git.