<?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[How Git Works Internally]]></title><description><![CDATA[How Git Works Internally]]></description><link>https://howgitworkk.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 18 Sep 2026 05:57:43 GMT</lastBuildDate><atom:link href="https://howgitworkk.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[We run commands like git add, git commit, git push — and things just work.But at some point, a question naturally comes up:
What is Git actually doing behind the scenes?
Understanding Git internally doesn’t make you a Git wizard overnight, but it doe...]]></description><link>https://howgitworkk.hashnode.dev/inside-git-how-it-works-and-the-role-of-the-git-folder-1</link><guid isPermaLink="true">https://howgitworkk.hashnode.dev/inside-git-how-it-works-and-the-role-of-the-git-folder-1</guid><dc:creator><![CDATA[Aditya Tomar]]></dc:creator><pubDate>Fri, 16 Jan 2026 11:32:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1768563126931/5de8c57d-53de-4949-8d6e-449e56f1a280.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>We run commands like <code>git add</code>, <code>git commit</code>, <code>git push</code> — and things <em>just work</em>.<br />But at some point, a question naturally comes up:</p>
<p><strong>What is Git actually doing behind the scenes?</strong></p>
<p>Understanding Git internally doesn’t make you a Git wizard overnight, but it <em>does</em> remove a lot of fear and confusion. Let’s open the black box.</p>
<hr />
<h2 id="heading-how-git-works-internally-high-level-view">How Git Works Internally (High-Level View)</h2>
<p>At its core, Git is <strong>not</strong> a tool that tracks files.<br />It is a tool that tracks <strong>snapshots of content</strong>.</p>
<p>Every time you commit, Git:</p>
<ul>
<li><p>Takes the current state of your project</p>
</li>
<li><p>Breaks it into objects</p>
</li>
<li><p>Stores those objects in a smart, efficient way</p>
</li>
</ul>
<p>Git doesn’t store differences like “line 5 changed from X to Y” by default.<br />Instead, it stores <strong>what the project looks like at that moment</strong>.</p>
<p>Everything Git does revolves around one hidden folder:</p>
<p>👉 <code>.git</code></p>
<hr />
<h2 id="heading-understanding-the-git-folder">Understanding the <code>.git</code> Folder</h2>
<p>When you run <code>git init</code>, Git creates a hidden <code>.git</code> directory in your project.</p>
<p>This folder is the <strong>entire Git database</strong>.<br />If you delete it, your project is no longer a Git repository.</p>
<p>Some important contents inside <code>.git</code>:</p>
<h3 id="heading-objects"><code>objects/</code></h3>
<p>This is where Git stores all data — commits, files, directories — everything.</p>
<h3 id="heading-refs"><code>refs/</code></h3>
<p>Keeps track of branches and tags.<br />A branch is simply a pointer to a commit.</p>
<h3 id="heading-head"><code>HEAD</code></h3>
<p>Tells Git which branch (or commit) you are currently on.</p>
<h3 id="heading-config"><code>config</code></h3>
<p>Repository-specific configuration.</p>
<p>In short:</p>
<blockquote>
<p><strong>Your code lives outside</strong> <code>.git</code>, but Git’s brain lives inside <code>.git</code>.</p>
</blockquote>
<hr />
<h2 id="heading-git-objects-the-building-blocks-of-git">Git Objects: The Building Blocks of Git</h2>
<p>Internally, Git stores data as <strong>objects</strong>.<br />There are four main types, but three are the most important.</p>
<h3 id="heading-1-blob-binary-large-object">1. Blob (Binary Large Object)</h3>
<p>A <strong>blob</strong> stores the <strong>content of a file</strong> — not the filename, not permissions, just raw data.</p>
<p>Important points:</p>
<ul>
<li><p>Same content = same blob (even across different files)</p>
</li>
<li><p>Git avoids duplication automatically</p>
</li>
</ul>
<p>Example:<br />If two files have identical content, Git stores only <strong>one blob</strong>.</p>
<hr />
<h3 id="heading-2-tree">2. Tree</h3>
<p>A <strong>tree</strong> represents a directory.</p>
<p>It contains:</p>
<ul>
<li><p>File names</p>
</li>
<li><p>Directory structure</p>
</li>
<li><p>Pointers to blobs and other trees</p>
</li>
</ul>
<p>Think of a tree as a <strong>folder snapshot</strong>.</p>
<p>A tree object answers:</p>
<blockquote>
<p>“What files exist here, and what blobs represent them?”</p>
</blockquote>
<hr />
<h3 id="heading-3-commit">3. Commit</h3>
<p>A <strong>commit</strong> ties everything together.</p>
<p>A commit object contains:</p>
<ul>
<li><p>A pointer to a tree (project snapshot)</p>
</li>
<li><p>Parent commit(s)</p>
</li>
<li><p>Author information</p>
</li>
<li><p>Commit message</p>
</li>
<li><p>Timestamp</p>
</li>
</ul>
<p>This is why Git history forms a <strong>chain of commits</strong>.</p>
<p>Each commit knows:</p>
<ul>
<li><p>What the project looked like</p>
</li>
<li><p>What came before it</p>
</li>
</ul>
<hr />
<h3 id="heading-simple-relationship">Simple Relationship</h3>
<pre><code class="lang-plaintext">Commit → Tree → Blobs
</code></pre>
<p>That’s it.<br />This simple model is the foundation of Git.</p>
<hr />
<h2 id="heading-how-git-tracks-changes-the-real-magic">How Git Tracks Changes (The Real Magic)</h2>
<p>Git does <strong>not</strong> track changes file-by-file like traditional systems.</p>
<p>Instead:</p>
<ol>
<li><p>When you modify a file, Git creates a <strong>new blob</strong> for that content</p>
</li>
<li><p>A new tree is created if structure changes</p>
</li>
<li><p>A new commit points to the new tree</p>
</li>
</ol>
<p>Old data is <strong>never overwritten</strong>.</p>
<p>This is why Git is:</p>
<ul>
<li><p>Fast</p>
</li>
<li><p>Reliable</p>
</li>
<li><p>Safe</p>
</li>
</ul>
<p>You’re not editing history — you’re <em>adding</em> to it.</p>
<hr />
<h2 id="heading-why-this-design-is-brilliant">Why This Design is Brilliant</h2>
<p>Understanding Git internals explains many Git behaviors:</p>
<h3 id="heading-why-commits-are-cheap">Why commits are cheap</h3>
<p>They’re just lightweight objects pointing to existing data.</p>
<h3 id="heading-why-branching-is-fast">Why branching is fast</h3>
<p>A branch is just a pointer to a commit.</p>
<h3 id="heading-why-git-rarely-loses-data">Why Git rarely loses data</h3>
<p>Objects are immutable — once created, they don’t change.</p>
<h3 id="heading-why-you-can-recover-lost-commits">Why you can recover “lost” commits</h3>
<p>They often still exist in the object database.</p>
<hr />
<h2 id="heading-conclusion">Conclusion:</h2>
<p>You don’t need to understand Git internals to use Git —<br />but once you do, Git stops feeling mysterious.</p>
<p>Commands start to make sense.<br />Errors become easier to reason about.<br />And Git transforms from a “tool I memorize” into a “system I understand”.</p>
<p>If Git ever felt scary, this is the layer that removes that fear.</p>
]]></content:encoded></item><item><title><![CDATA[Inside Git: How It Works and the Role of the .git Folder]]></title><description><![CDATA[We run commands like git add, git commit, git push — and things just work.But at some point, a question naturally comes up:
What is Git actually doing behind the scenes?
Understanding Git internally doesn’t make you a Git wizard overnight, but it doe...]]></description><link>https://howgitworkk.hashnode.dev/inside-git-how-it-works-and-the-role-of-the-git-folder</link><guid isPermaLink="true">https://howgitworkk.hashnode.dev/inside-git-how-it-works-and-the-role-of-the-git-folder</guid><dc:creator><![CDATA[Aditya Tomar]]></dc:creator><pubDate>Fri, 16 Jan 2026 11:29:52 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1768562972121/abe74ba6-cd32-4492-a0d4-ab5340f03deb.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>We run commands like <code>git add</code>, <code>git commit</code>, <code>git push</code> — and things <em>just work</em>.<br />But at some point, a question naturally comes up:</p>
<p><strong>What is Git actually doing behind the scenes?</strong></p>
<p>Understanding Git internally doesn’t make you a Git wizard overnight, but it <em>does</em> remove a lot of fear and confusion. Let’s open the black box.</p>
<hr />
<h2 id="heading-how-git-works-internally-high-level-view">How Git Works Internally (High-Level View)</h2>
<p>At its core, Git is <strong>not</strong> a tool that tracks files.<br />It is a tool that tracks <strong>snapshots of content</strong>.</p>
<p>Every time you commit, Git:</p>
<ul>
<li><p>Takes the current state of your project</p>
</li>
<li><p>Breaks it into objects</p>
</li>
<li><p>Stores those objects in a smart, efficient way</p>
</li>
</ul>
<p>Git doesn’t store differences like “line 5 changed from X to Y” by default.<br />Instead, it stores <strong>what the project looks like at that moment</strong>.</p>
<p>Everything Git does revolves around one hidden folder:</p>
<p>👉 <code>.git</code></p>
<hr />
<h2 id="heading-understanding-the-git-folder">Understanding the <code>.git</code> Folder</h2>
<p>When you run <code>git init</code>, Git creates a hidden <code>.git</code> directory in your project.</p>
<p>This folder is the <strong>entire Git database</strong>.<br />If you delete it, your project is no longer a Git repository.</p>
<p>Some important contents inside <code>.git</code>:</p>
<h3 id="heading-objects"><code>objects/</code></h3>
<p>This is where Git stores all data — commits, files, directories — everything.</p>
<h3 id="heading-refs"><code>refs/</code></h3>
<p>Keeps track of branches and tags.<br />A branch is simply a pointer to a commit.</p>
<h3 id="heading-head"><code>HEAD</code></h3>
<p>Tells Git which branch (or commit) you are currently on.</p>
<h3 id="heading-config"><code>config</code></h3>
<p>Repository-specific configuration.</p>
<p>In short:</p>
<blockquote>
<p><strong>Your code lives outside</strong> <code>.git</code>, but Git’s brain lives inside <code>.git</code>.</p>
</blockquote>
<hr />
<h2 id="heading-git-objects-the-building-blocks-of-git">Git Objects: The Building Blocks of Git</h2>
<p>Internally, Git stores data as <strong>objects</strong>.<br />There are four main types, but three are the most important.</p>
<h3 id="heading-1-blob-binary-large-object">1. Blob (Binary Large Object)</h3>
<p>A <strong>blob</strong> stores the <strong>content of a file</strong> — not the filename, not permissions, just raw data.</p>
<p>Important points:</p>
<ul>
<li><p>Same content = same blob (even across different files)</p>
</li>
<li><p>Git avoids duplication automatically</p>
</li>
</ul>
<p>Example:<br />If two files have identical content, Git stores only <strong>one blob</strong>.</p>
<hr />
<h3 id="heading-2-tree">2. Tree</h3>
<p>A <strong>tree</strong> represents a directory.</p>
<p>It contains:</p>
<ul>
<li><p>File names</p>
</li>
<li><p>Directory structure</p>
</li>
<li><p>Pointers to blobs and other trees</p>
</li>
</ul>
<p>Think of a tree as a <strong>folder snapshot</strong>.</p>
<p>A tree object answers:</p>
<blockquote>
<p>“What files exist here, and what blobs represent them?”</p>
</blockquote>
<hr />
<h3 id="heading-3-commit">3. Commit</h3>
<p>A <strong>commit</strong> ties everything together.</p>
<p>A commit object contains:</p>
<ul>
<li><p>A pointer to a tree (project snapshot)</p>
</li>
<li><p>Parent commit(s)</p>
</li>
<li><p>Author information</p>
</li>
<li><p>Commit message</p>
</li>
<li><p>Timestamp</p>
</li>
</ul>
<p>This is why Git history forms a <strong>chain of commits</strong>.</p>
<p>Each commit knows:</p>
<ul>
<li><p>What the project looked like</p>
</li>
<li><p>What came before it</p>
</li>
</ul>
<hr />
<h3 id="heading-simple-relationship">Simple Relationship</h3>
<pre><code class="lang-plaintext">Commit → Tree → Blobs
</code></pre>
<p>That’s it.<br />This simple model is the foundation of Git.</p>
<hr />
<h2 id="heading-how-git-tracks-changes-the-real-magic">How Git Tracks Changes (The Real Magic)</h2>
<p>Git does <strong>not</strong> track changes file-by-file like traditional systems.</p>
<p>Instead:</p>
<ol>
<li><p>When you modify a file, Git creates a <strong>new blob</strong> for that content</p>
</li>
<li><p>A new tree is created if structure changes</p>
</li>
<li><p>A new commit points to the new tree</p>
</li>
</ol>
<p>Old data is <strong>never overwritten</strong>.</p>
<p>This is why Git is:</p>
<ul>
<li><p>Fast</p>
</li>
<li><p>Reliable</p>
</li>
<li><p>Safe</p>
</li>
</ul>
<p>You’re not editing history — you’re <em>adding</em> to it.</p>
<hr />
<h2 id="heading-why-this-design-is-brilliant">Why This Design is Brilliant</h2>
<p>Understanding Git internals explains many Git behaviors:</p>
<h3 id="heading-why-commits-are-cheap">Why commits are cheap</h3>
<p>They’re just lightweight objects pointing to existing data.</p>
<h3 id="heading-why-branching-is-fast">Why branching is fast</h3>
<p>A branch is just a pointer to a commit.</p>
<h3 id="heading-why-git-rarely-loses-data">Why Git rarely loses data</h3>
<p>Objects are immutable — once created, they don’t change.</p>
<h3 id="heading-why-you-can-recover-lost-commits">Why you can recover “lost” commits</h3>
<p>They often still exist in the object database.</p>
<hr />
<h2 id="heading-final-thoughts">Final Thoughts</h2>
<p>You don’t need to understand Git internals to use Git —<br />but once you do, Git stops feeling mysterious.</p>
<p>Commands start to make sense.<br />Errors become easier to reason about.<br />And Git transforms from a “tool I memorize” into a “system I understand”.</p>
<p>If Git ever felt scary, this is the layer that removes that fear.</p>
]]></content:encoded></item></channel></rss>