š§ How Git Actually Works Internally
Itās more than just git add . && git commit -m "done"
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 =f572d396fae9206628714fb2ce00f72e94f2258fAdd 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 āmainnow 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āmainmainā 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
HEADpoints 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.


