How Git Works Internally

Learning web development in public. Writing simple, real-world explanations about web development concepts. Helping beginners understand why things work, not just how.
Search for a command to run...

Learning web development in public. Writing simple, real-world explanations about web development concepts. Helping beginners understand why things work, not just how.
No comments yet. Be the first to comment.
Every day, millions of users upload photos, videos, stories, and reels to Instagram. From a user's perspective, the process appears simple: select media, apply filters, add a caption, and tap "Post."
Building Offline-First Messaging Apps: How Messages Work Without Internet Modern messaging applications have transformed the way people communicate. Whether it's chatting with friends, collaborating w
In this article we'll explore about the Expo Router and React Navigation and answer which one to use in 2026. If you build mobile apps using React Native, one thing becomes obvious very quickly: Navig

Modern mobile apps are no longer just a collection of screens connected together. Apps like Instagram, WhatsApp, Uber, and Netflix operate at massive scale with millions of users, real time systems, o
In this article we'll be exploring react.js and the things of react.js that makes it popular and stand out among other libraries ( no fight over library vs framework ). We'll go through: What problem

Shkaai
68 posts
In this article we will dive into how actually Git works and how it magically remembers all the versions of our code files. Well before moving on we need to know one simple idea that “Git is a memory box of your project”. It remembers each and every version of your code. so you can:
go back in time
track what changed
and work safely without fear
Everything git knows lives in one place.
When you run:
git init
Git creates a hidden folder called .git
You can think of .git folder as Git’s brain.
Your files = body
.git folder = brain
No brain → no memory → no Git
So if you delete .git folder
❌ No history
❌ No commits
❌ No branches
It just becomes a normal folder again. That is how powerful .git folder is.
Git stores snapshots.
📸 A snapshot =
“How all files looked at one moment”
Not instructions.
Not diffs.
Pictures of your project.

Git uses only 3 main blocks:
The text inside a file
Git doesn’t care about file names here
Knows:
file names
which content belongs to which file
A commit says:
Which files existed
What was inside them
A message like: “Add login feature”
git addYou run:
git add file.js
Git does this:
Reads the file content
Saves it safely in .git
Adds it to the staging checklist
That’s it.
❗ git add does NOT save history
❗ It only prepares
git commitNow Git takes the photo 📸
When you run:
git commit -m "message"
Git:
Looks at the staging checklist
Takes a snapshot
Stores it forever
Moves the timeline forward
🎉 That snapshot is your commit.
Git gives everything a unique ID.
Like:
Aadhaar number
Fingerprint 🖐️
If the content changes:
➡️ the ID changes
This means:
No fake history
No silent changes
100% trust
Git is a memory system for your code. It remembers every version of your project.
The .git folder is Git’s brain. All history, commits, and branches live there.
Git saves snapshots, not just changes.
Your files live in the working directory.
The staging area is a checklist of what will go into the next snapshot.
git add = choose files for the snapshot.
git commit = take the snapshot and save it forever.
Git uses hashes (unique IDs) to make sure nothing is changed or corrupted.
-- Mental model: edit → select → snapshot → remember forever.