<?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 and the Role]]></title><description><![CDATA[Inside Git: How It Works and the Role]]></description><link>https://inside-git-the-working.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Sep 2026 14:44:14 GMT</lastBuildDate><atom:link href="https://inside-git-the-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[Most beginners use Git like a magic box.
You type a few commands, things “work”, and you move on.But the moment something breaks, Git suddenly feels scary.
The truth is: Git is not magic.It’s just very systematic.
This blog is about what Git is doing...]]></description><link>https://inside-git-the-working.hashnode.dev/inside-git-how-it-works-and-the-role-of-the-git-folder</link><guid isPermaLink="true">https://inside-git-the-working.hashnode.dev/inside-git-how-it-works-and-the-role-of-the-git-folder</guid><category><![CDATA[#git#github#Chai]]></category><dc:creator><![CDATA[Navneet Mishra]]></dc:creator><pubDate>Sat, 31 Jan 2026 10:06:02 GMT</pubDate><content:encoded><![CDATA[<p>Most beginners use Git like a magic box.</p>
<p>You type a few commands, things “work”, and you move on.<br />But the moment something breaks, Git suddenly feels scary.</p>
<p>The truth is: <strong>Git is not magic</strong>.<br />It’s just very systematic.</p>
<p>This blog is about <strong>what Git is doing behind the scenes</strong>, so you can <em>understand</em> it instead of memorizing commands.</p>
<hr />
<h2 id="heading-first-things-first-what-is-the-git-folder">First Things First: What Is the <code>.git</code> Folder?</h2>
<p>When you run:</p>
<p>Git creates a hidden folder called: <code>git init</code></p>
<p>This folder is <strong>Git itself</strong>.</p>
<p>Your project files are <em>not</em> Git.<br />Your code is <em>not</em> Git.<br />The <code>.git</code> folder is where Git stores <strong>everything it knows</strong> about your project.</p>
<p>If you delete the <code>.git</code> folder:</p>
<ul>
<li><p>Your code stays</p>
</li>
<li><p>Git history is gone</p>
</li>
<li><p>Commits disappear</p>
</li>
<li><p>It’s no longer a Git repository</p>
</li>
</ul>
<h2 id="heading-how-git-thinks-about-your-project">How Git Thinks About Your Project</h2>
<p>Git does <strong>not</strong> track files like Google Drive or Dropbox.</p>
<p>Git tracks:</p>
<ul>
<li><p><strong>content</strong></p>
</li>
<li><p>not filenames</p>
</li>
<li><p>not folders</p>
</li>
<li><p>not “versions” the way humans think</p>
</li>
</ul>
<p>Git stores <strong>snapshots</strong>, not differences.</p>
<p>Each snapshot answers one question:</p>
<p><strong>What did the project look like at this moment?</strong></p>
<hr />
<h2 id="heading-git-objects-the-building-blocks">Git Objects: The Building Blocks</h2>
<p>Inside the <code>.git</code> folder, Git stores everything as <strong>objects</strong>.</p>
<p>There are only <strong>three core ones you need to understand</strong>.</p>
<h3 id="heading-1-blob-the-file-content">1. Blob — The File Content</h3>
<p>A <strong>blob</strong> is just:</p>
<ul>
<li><p>the <strong>content</strong> of a file</p>
</li>
<li><p>not the filename</p>
</li>
<li><p>not the location</p>
</li>
</ul>
<p>If two files have the same content, Git stores <strong>one blob</strong>.</p>
<p>Think: Blob = This exact text exists</p>
<h3 id="heading-2-tree-folder-structure">2. Tree — Folder Structure</h3>
<p>A <strong>tree</strong> represents:</p>
<ul>
<li><p>folders</p>
</li>
<li><p>file names</p>
</li>
<li><p>how blobs are arranged</p>
</li>
</ul>
<p>It connects:</p>
<ul>
<li><p>filenames → blobs</p>
</li>
<li><p>directories → other trees</p>
</li>
</ul>
<h3 id="heading-3-commit-a-snapshot-with-context">3. Commit — A Snapshot With Context</h3>
<p>A <strong>commit</strong> points to:</p>
<ul>
<li><p>one tree (project structure)</p>
</li>
<li><p>parent commit(s)</p>
</li>
<li><p>author</p>
</li>
<li><p>message</p>
</li>
<li><p>timestamp</p>
</li>
</ul>
<h3 id="heading-simple-analogy">Simple Analogy</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Git Object</td><td>Real-world idea</td></tr>
</thead>
<tbody>
<tr>
<td>Blob</td><td>File content</td></tr>
<tr>
<td>Tree</td><td>Folder structure</td></tr>
<tr>
<td>Commit</td><td>A saved snapshot</td></tr>
</tbody>
</table>
</div><p>That’s it. No mystery.</p>
<h2 id="heading-what-actually-happens-when-you-git-add">What Actually Happens When You <code>git add</code></h2>
<p>This is where beginners get confused.</p>
<p><code>git add</code> <strong>does NOT save your project</strong>.</p>
<p>Instead, Git:</p>
<ol>
<li><p>Reads the file content</p>
</li>
<li><p>Converts it into blobs</p>
</li>
<li><p>Stores them inside <code>.git/objects</code></p>
</li>
<li><p>Prepares a snapshot <strong>candidate</strong></p>
</li>
</ol>
<p>This area is called the <strong>staging area</strong>.</p>
<hr />
<h2 id="heading-what-happens-when-you-git-commit">What Happens When You <code>git commit</code></h2>
<p>Now Git:</p>
<ol>
<li><p>Takes everything from the staging area</p>
</li>
<li><p>Creates trees (structure)</p>
</li>
<li><p>Creates a commit object</p>
</li>
<li><p>Links it to the previous commit</p>
</li>
<li><p>Stores it permanently</p>
</li>
</ol>
<h2 id="heading-how-git-tracks-changes-the-smart-part">How Git Tracks Changes (The Smart Part)</h2>
<p>Git doesn’t say:</p>
<p><strong>Line 3 changed from A to B</strong></p>
<p>Instead, it says:</p>
<p><strong>This snapshot exists.<br />This other snapshot also exists.</strong></p>
<p>Differences are <strong>calculated later</strong>, not stored.</p>
<p>This makes Git:</p>
<ul>
<li><p>fast</p>
</li>
<li><p>reliable</p>
</li>
<li><p>powerful for branching</p>
</li>
</ul>
<hr />
<h2 id="heading-why-hashes-matter-and-why-git-is-hard-to-corrupt">Why Hashes Matter (And Why Git Is Hard to Corrupt)</h2>
<p>Every Git object has a <strong>hash</strong> (a long string like this):</p>
<p><code>a3f5c1e9...</code></p>
<p>This hash is created from:</p>
<ul>
<li>the content itself</li>
</ul>
<p>If content changes → hash changes.</p>
<p>This gives Git two superpowers:</p>
<ol>
<li><p><strong>Integrity</strong> – corrupted data is detected</p>
</li>
<li><p><strong>Deduplication</strong> – same content is stored once</p>
</li>
</ol>
<p><strong><em>“Git doesn’t trust names.<br />Git trusts math.”</em></strong></p>
<hr />
<h2 id="heading-why-this-mental-model-matters-more-than-commands">Why This Mental Model Matters More Than Commands</h2>
<p>If you only memorize commands:</p>
<ul>
<li><p>Git feels fragile</p>
</li>
<li><p>Errors feel random</p>
</li>
<li><p>You panic during conflicts</p>
</li>
</ul>
<p>If you understand:</p>
<ul>
<li><p>blobs</p>
</li>
<li><p>trees</p>
</li>
<li><p>commits</p>
</li>
<li><p>snapshots</p>
</li>
</ul>
<p>Then Git becomes predictable.</p>
<p>You stop asking:</p>
<blockquote>
<p>“What command should I run?”</p>
</blockquote>
<p>And start thinking:</p>
<blockquote>
<p>“What state do I want my project in?”</p>
</blockquote>
<hr />
<h2 id="heading-final-thought">Final Thought</h2>
<p>Git is not about commands.<br />Git is about <strong>states and history</strong>.</p>
<p>Once that clicks, everything else:</p>
<ul>
<li><p>branches</p>
</li>
<li><p>merges</p>
</li>
<li><p>rebases</p>
</li>
</ul>
<p>becomes less scary.</p>
<p>You’re not fighting Git.<br />You’re just telling it what to remember.</p>
]]></content:encoded></item></channel></rss>