Inside Git: The Hidden Engine
Understanding What Really Happens Inside Git - Without Fear
Search for a command to run...
Understanding What Really Happens Inside Git - Without Fear
Think of a situation where two people are talking on the phone line. One person speaks, but the other does not reply. Some words get cut off, some sentences repeat, noise in between, and some never arrive at all. After sometime, the connection breaks...
Think about this for a moment. You open a browser and visit a website like kartikeynarayan.in on your mobile phone, laptop, or any other device. The website loads instantly, without you needing to think about what happens behind the scenes. But have ...
You type a website address into your browser and press Enter. Within seconds, the page loads, no questions asked. At that moment, a natural question arises in the mind of the end user: “How does a browser know where a website lives?” More questions...
Think of a situation where two people are talking on the phone line. One person speaks, but the other does not reply. Some words get cut off, some sentences repeat, noise in between, and some never arrive at all. After sometime, the connection breaks...
A Story of Lost Code and Why History Matters
This chapter is not about learning new Git commands.
It’s about answering the question every curious developer eventually asks:
“What is Git actually doing behind the scenes?”
This is the story of Kartikey going one level deeper inside Git itself.
“This is where Kartikey’s journey begins.”
Kartikey has been using Git for a while now.
He can commit.
He can create branches.
He feels comfortable.
Then one day, while exploring his project folder, he notices something unusual.
A hidden directory.
.git
Kartikey pauses.
“What is this folder… and why does it exist?”
Git doesn’t answer immediately.
Finally, Git speaks.
“Everything you trust me for lives here.”
Kartikey opens the .git folder.
It’s not code.
It’s not configuration alone.
It’s Git’s entire memory.
Git explains:
This folder stores history.
This folder stores snapshots.
This folder stores relationships.
This folder stores integrity.
Then Git adds quietly:
“Delete this folder and I forget everything.”
Kartikey understands.
The .git folder isn’t optional.
It is Git.
Kartikey assumes Git tracks files line by line.
Git corrects him.
“I don’t track files.”
“I track content.”
Whenever Kartikey writes code, Git doesn’t care about:
File names
Folder names
Git only cares about:
What the content is?
Whether it has changed?
That’s when Git introduces its core building blocks.
Git draws three symbols in the air:
Blob
Tree
Commit
“Everything I store is one of these.”
A blob is just raw content.
No filename
No folder
Just data
If two files have the same content, Git stores only one blob.
Git says calmly:
“I don’t duplicate memory” .
A tree represents:
Folder structure
File names
How blobs are arranged.
Think of a tree as a map, not the content itself.
A commit ties everything together.
It points to:
One tree (structure)
Previous commit(s)
Metadata (author, message, time)
Git explains:
“A commit is not a change.”
“It’s a snapshot.”
Kartikey starts seeing Git differently.
Kartikey types:
git add index.js
Nothing seems to change.
But inside Git, everything changes.
Git explains:
Git reads the file content.
Git creates a blob.
Git calculates a hash.
Git stores it inside .git/objects.
Git updates the index (staging area).
Git adds:
“The staging area is a list of hashes, I’m preparing to remember.”
Kartikey realizes something important:
git add doesn’t save history, It prepares reality.
Now Kartikey commits:
git commit -m "Save progress of index.js file."
Git goes to work.
Internally:
Git creates a tree from staged blobs.
Git creates a commit object.
Git links it to the previous commit.
Git moves HEAD forward.
Git says:
“This is when time moves forward.”
Kartikey understands:
Commits don’t store differences.
They store complete snapshots, efficiently.
Kartikey notices strange strings everywhere.
Long.
Random.
Unreadable.
Git explains:
“Those are hashes.”
Every blob, tree, and commit is identified by a cryptographic hash (SHA-1 or SHA-256).
This means:
Change the content → the hash changes.
Corrupt the data → the hash does not match.
History cannot be secretly altered.
Git says calmly:
“My memory is tamper-proof.”
Kartikey finally understands why Git feels so reliable.
Git summarizes:
Files → Blobs
Folders → Trees
Snapshots → Commits
Hashes → Identity
.git folder → Memory
Git tells Kartikey:
“Don’t memorize commands.”
“Understand how I think.”
That’s when it clicks.
Kartikey looks at Git differently now.
Not as magic.
Not as commands.
But as a content-addressed memory system.
He smiles.
Because now:
Git feels predictable.
Git feels safe.
Git feels logical.
And once again, Kartikey realizes:
“Git doesn’t just help him write code.”
“It helps him trust his progress.”
If Git has ever felt mysterious, you’re not alone.
Understanding Git internally doesn’t make you a power user, it makes you a calm developer.