Most People Think Git Tracks Line Changes
If you think Git is like Google Docs version history — tracking line-by-line changes — you're not alone.
But Git is way smarter than that.
Git doesn’t store diffs.
Instead, it uses a snapshot-based model, powered by SHA-1 hashes, blobs, trees, and pointers.
Let’s break it all down.
🔐 SHA-1: The Foundation of Git
Every file, folder, and commit in Git is identified by a SHA-1 hash — a unique 40-character string.
If you change even one letter in a file, Git generates a completely different SHA-1 hash.
For example:
A file with contentHello
→
SHA-1 =f572d396fae9206628714fb2ce00f72e94f2258f
Add a space →
New SHA-1 = Totally different value.
Git uses this to track unique versions of content efficiently and securely.
📸 Git Stores Snapshots, Not Diffs
Here’s the mind-blowing part:
Git stores the full snapshot of your files at the time of commit, not just the changes.
Imagine taking a full photo of your project every time you commit.
But wait — doesn’t that waste space?
Nope. Because Git is smart enough to reuse unchanged files (blobs) across commits.
So only the new or modified files get stored again.
🧱 Git’s Data Model: Blobs and Trees
Git’s internal structure is made of:
Blob: Actual file content (binary large object)
Tree: Represents a directory, points to blobs or other trees
Commit: Points to one tree + parent commits + metadata
Each commit stores:
Author & message
Timestamp
A pointer to a tree
A pointer to its parent commit(s)
This creates a linked list of commits — aka your Git history.
🌿 Branches Are Just Pointers
A branch is not a separate folder or copy.
It’s literally just a pointer to a specific commit.
When you make a new commit, the branch pointer just moves forward to point to the latest one.
main
→ commit A
After commit B →main
now points to B
Lightweight. Instant. Simple.
🧭 HEAD: Pointer to a Pointer
HEAD
in Git is a special pointer that points to the current branch you're working on.
So:
HEAD
→main
main
→ commit Ccommit C → tree → blobs
This chain helps Git always know where you are and what you're working on.
🔁 Everything Is Immutable
Another thing Git is known for — immutability.
Once a commit is made, you can’t change its hash.
If you amend a commit, Git actually creates a new one with a new SHA-1 and updates the pointer.
That’s why Git is so powerful for collaboration and version safety.
🧠 TL;DR – Git Internals
Git uses SHA-1 hashes to track files, folders, and commits
Commits are snapshots, not diffs
Blobs = file content, Trees = folder structure
Branches are just pointers to commits
HEAD
points to the current branchEverything is immutable and traceable
Git is more than a version control system — it's a beautifully designed data structure that helps millions of developers work without breaking things.
Next time you hit commit
, know you’re snapshotting an entire world with just one command.
💬 Found this useful?
Let me know your Git questions, and I’ll cover them in future posts.
Save this blog for your next system design interview prep or Git deep dive.