<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Inside Git: How It Works inside .git]]></title><description><![CDATA[Inside Git: How It Works inside .git]]></description><link>https://internal-of-git-working.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 11 Sep 2026 08:58:27 GMT</lastBuildDate><atom:link href="https://internal-of-git-working.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Inside Git: How It Works and the Role of the .git Folder]]></title><description><![CDATA[✅How Git Works Internally:
When I first learned Git, I used commands without really knowing what was happening.Things worked—but Git felt confusing.
If you’ve ever wondered:

What actually happens when I run git add?

Where does Git store my code?

H...]]></description><link>https://internal-of-git-working.hashnode.dev/inside-git-how-it-works-and-the-role-of-the-git-folder</link><guid isPermaLink="true">https://internal-of-git-working.hashnode.dev/inside-git-how-it-works-and-the-role-of-the-git-folder</guid><category><![CDATA[GitHub]]></category><category><![CDATA[Internals]]></category><category><![CDATA[git-folder-architecture]]></category><category><![CDATA[insidegit]]></category><dc:creator><![CDATA[Joydeep Garai]]></dc:creator><pubDate>Sat, 17 Jan 2026 07:53:31 GMT</pubDate><content:encoded><![CDATA[<h2 id="heading-how-git-works-internally">✅How Git Works Internally:</h2>
<p>When I first learned Git, I used commands without really knowing <em>what was happening</em>.<br />Things worked—but Git felt confusing.</p>
<p>If you’ve ever wondered:</p>
<ul>
<li><p>What actually happens when I run <code>git add</code>?</p>
</li>
<li><p>Where does Git store my code?</p>
</li>
<li><p>How does Git remember every version?</p>
</li>
</ul>
<p>This blog is for you.</p>
<p><strong>We’ll look at how Git works internally, not in a complicated way, but in a way that makes Git feel logical.</strong></p>
<h2 id="heading-first-understand-this-one-thing">First, Understand This One Thing 🧠</h2>
<p>Git is <strong>not a file tracker</strong>.<br />Git is a <strong>content tracker</strong>.</p>
<p>It does not think in terms of <em>files and folders</em>.<br />It thinks in terms of <em>content and snapshots</em>.</p>
<p>And everything Git does happens inside <strong>one hidden folder</strong>:</p>
<blockquote>
<p>📁 <code>.git</code></p>
</blockquote>
<p>Once this clicks, Git stops feeling magical.</p>
<h2 id="heading-the-git-folder-the-heart-of-git">The <code>.git</code> Folder: The Heart of Git ❤️</h2>
<p>When you initialize a Git repository, Git creates a hidden folder called <code>.git</code>.</p>
<p>This folder contains:</p>
<ul>
<li><p>The entire history of your project</p>
</li>
<li><p>All commits</p>
</li>
<li><p>Branch information</p>
</li>
<li><p>Internal data Git uses to work</p>
</li>
</ul>
<p>Important thing to remember:</p>
<blockquote>
<p>Your project files are outside <code>.git</code>,<br />but <strong>Git’s memory lives inside</strong> <code>.git</code>.</p>
</blockquote>
<p>If this folder is removed, Git forgets everything.</p>
<p><strong>What’s Inside the</strong> <code>.git</code> <strong>Folder</strong></p>
<p><strong><em>.git/ ├── objects/ ├── refs/ ├── HEAD ├── index └── config objects/ → where Git stores actual data</em></strong></p>
<p>refs/ → keeps track of branches</p>
<p>HEAD → tells Git where you currently are</p>
<p>index → staging area data</p>
<p>config → project-level settings</p>
<p>Git doesn’t store history in your files. It stores history here.</p>
<h2 id="heading-git-objects-how-git-stores-everything">Git Objects: How Git Stores Everything 🧱</h2>
<p>Internally, Git stores data as <strong>objects</strong>.</p>
<p>Every object is saved using a <strong>hash</strong>, which is like a unique fingerprint.<br />If the content changes, the fingerprint changes.</p>
<p>There are <strong>three core Git objects</strong> you need to understand.</p>
<p>Nothing more. Nothing less.</p>
<h2 id="heading-blob-where-file-content-lives">Blob: Where File Content Lives 📄</h2>
<p>A <strong>blob</strong> stores the <strong>actual content</strong> of a file.</p>
<p>That’s it.</p>
<p>Important things:</p>
<ul>
<li><p>It does <strong>not</strong> store the filename</p>
</li>
<li><p>It stores only the content</p>
</li>
<li><p>Same content = same blob</p>
</li>
</ul>
<p>So if two files have identical content, Git stores it only once.</p>
<p>Git cares about <em>what’s inside the file</em>, not <em>what the file is called</em>.</p>
<h2 id="heading-tree-how-git-understands-folders">Tree: How Git Understands Folders 📁</h2>
<p>A <strong>tree</strong> represents a directory.</p>
<p>It stores:</p>
<ul>
<li><p>File names</p>
</li>
<li><p>Links to blob objects</p>
</li>
<li><p>Links to other trees (subfolders)</p>
</li>
</ul>
<p>Think of a tree as a <strong>structure map</strong>.</p>
<p>It tells Git:</p>
<blockquote>
<p>“This file name points to this content.”</p>
<h2 id="heading-commit-a-snapshot-in-time">Commit: A Snapshot in Time 📸</h2>
<p>A <strong>commit</strong> is not just “saved code”.</p>
<p>A commit stores:</p>
<ul>
<li><p>A reference to a tree (project structure)</p>
</li>
<li><p>Author information</p>
</li>
<li><p>Commit message</p>
</li>
<li><p>Link to the previous commit</p>
</li>
</ul>
<p>A commit says:</p>
<blockquote>
<p>“This is exactly how the project looked at this moment.”</p>
</blockquote>
<p>Commits don’t store files directly.<br />They store <strong>references</strong>.</p>
<h2 id="heading-how-these-objects-connect">How These Objects Connect 🔗</h2>
<p>This is the most important relationship in Git:</p>
<pre><code class="lang-plaintext">Commit
  |
  └── Tree
        ├── file → Blob
        ├── file → Blob
        └── folder → Tree
</code></pre>
<p>Simple way to remember:</p>
<ul>
<li><p>Blob = content</p>
</li>
<li><p>Tree = structure</p>
</li>
<li><p>Commit = snapshot + history</p>
</li>
</ul>
<p>This is Git’s entire design.</p>
<h2 id="heading-how-git-tracks-changes-this-is-the-key">How Git Tracks Changes (This Is the Key 🔑)</h2>
<p>Git doesn’t compare files line by line.</p>
<p>Instead:</p>
<ul>
<li><p>Git calculates a hash of the content</p>
</li>
<li><p>If content changes → new hash</p>
</li>
<li><p>If content stays same → reuse old data</p>
</li>
</ul>
<p>This is why Git is:</p>
<ul>
<li><p>Fast</p>
</li>
<li><p>Reliable</p>
</li>
<li><p>Memory efficient</p>
</li>
</ul>
<p>Git tracks <strong>snapshots</strong>, not edits.</p>
<h2 id="heading-what-really-happens-during-git-add">What Really Happens During <code>git add</code></h2>
<p>Many beginners think <code>git add</code> saves the code.<br />It doesn’t.</p>
<p>Internally, Git:</p>
<ol>
<li><p>Reads file content</p>
</li>
<li><p>Creates a blob (if content is new)</p>
</li>
<li><p>Updates the <strong>index</strong> (staging area)</p>
</li>
</ol>
<p>Conceptually:</p>
<pre><code class="lang-plaintext">Working Directory → Blob → Index
</code></pre>
<p><code>git add</code> means:</p>
<blockquote>
<p>“I want this version of the content to be included in the next snapshot.”</p>
</blockquote>
<p>Nothing is permanent yet.</p>
<h2 id="heading-what-really-happens-during-git-commit"><strong>🧑‍💻</strong>What Really Happens During <code>git commit</code></h2>
<p>This is where history is created.</p>
<p>Internally, Git:</p>
<ol>
<li><p>Reads what’s in the staging area</p>
</li>
<li><p>Builds tree objects</p>
</li>
<li><p>Creates a commit object</p>
</li>
<li><p>Moves the branch pointer forward</p>
</li>
</ol>
<p>Conceptually:</p>
<pre><code class="lang-plaintext">Index → Tree → Commit → Branch
</code></pre>
<p>This is why:</p>
<blockquote>
<p>If something is not staged, it cannot be committed.</p>
<h2 id="heading-why-git-uses-hashes">Why Git Uses Hashes 🔐</h2>
<p>Every Git object is identified by a hash.</p>
<p>This gives Git three superpowers:</p>
<ul>
<li><p>Data integrity (corruption is detectable)</p>
</li>
<li><p>Exact version identification</p>
</li>
<li><p>Safe collaboration</p>
</li>
</ul>
<p>Even a tiny change creates a new hash.<br />That’s how Git knows something changed.</p>
<h2 id="heading-the-mental-model-that-makes-git-easy">The Mental Model That Makes Git Easy 🧠</h2>
<p>If you remember only this, Git will make sense:</p>
<ul>
<li><p>Git tracks <strong>content</strong></p>
</li>
<li><p>Everything lives inside <code>.git</code></p>
</li>
<li><p>Blobs store content</p>
</li>
<li><p>Trees store structure</p>
</li>
<li><p>Commits store snapshots</p>
</li>
<li><p>Hashes connect everything safely</p>
</li>
</ul>
<p>Commands are just a way to <em>talk to this system</em>.</p>
<h2 id="heading-final-thoughts">Final Thoughts 🌱</h2>
<p>Git is not hard by design.<br />It only feels hard when we use it without understanding it.</p>
<p>Once you understand how Git thinks internally, you stop guessing—and start using Git confidently.</p>
<p>This understanding will help you:</p>
<ul>
<li><p>Debug issues calmly</p>
</li>
<li><p>Learn advanced Git faster</p>
</li>
<li><p>Work professionally with teams</p>
</li>
</ul>
</blockquote>
</blockquote>
]]></content:encoded></item></channel></rss>