<?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[Git under the hood]]></title><description><![CDATA[Git under the hood]]></description><link>https://git-inside-dev.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 17:43:48 GMT</lastBuildDate><atom:link href="https://git-inside-dev.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[Why does the .git folder remain compact even after 1000 commits? How does Git efficiently track every change?
The .git Folder: Complete Project History
A single folder contains everything needed to reconstruct your entire project history.
Running git...]]></description><link>https://git-inside-dev.hashnode.dev/inside-git-how-it-works-and-the-role-of-the-git-folder</link><guid isPermaLink="true">https://git-inside-dev.hashnode.dev/inside-git-how-it-works-and-the-role-of-the-git-folder</guid><category><![CDATA[Git]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[github-actions]]></category><category><![CDATA[Developer]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Mohd Asif]]></dc:creator><pubDate>Sat, 17 Jan 2026 13:47:47 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1768657500979/c22344f9-5b3d-437c-9b43-69ff697800a7.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Why does the</strong> .git folder remain compact even after 1000 commits? How does Git efficiently track every change?</p>
<h2 id="heading-the-git-folder-complete-project-history"><strong>The</strong> <code>.git</code> Folder: Complete Project History</h2>
<p><strong>A single folder contains everything needed to reconstruct your entire project history.</strong></p>
<p>Running <code>git init</code> creates the hidden <code>.git</code> directory, which stores code history, branches, commits, and configuration.</p>
<p><strong>Practical application:</strong> Copy only the <code>.git</code> folder to another machine and run <code>git checkout</code> to restore your complete project.</p>
<h2 id="heading-git-directory-structure"><code>.git</code> <strong>Directory Structure</strong></h2>
<pre><code class="lang-bash">text.git/
├── objects/     <span class="hljs-comment"># File content and history storage</span>
├── refs/        <span class="hljs-comment"># Branch and tag references</span>
├── index        <span class="hljs-comment"># Staging area snapshot</span>
├── HEAD         <span class="hljs-comment"># Current branch pointer</span>
└── config       <span class="hljs-comment"># Repository configuration</span>
</code></pre>
<p>The <code>objects/</code> directory stores all content as compressed, hashed objects.</p>
<h2 id="heading-git-objects"><strong>Git Objects</strong></h2>
<h3 id="heading-blob-file-content-storage"><strong>Blob: File Content Storage</strong></h3>
<p>A blob represents the raw content of a single file, independent of its name or path.</p>
<p><strong>Key characteristics:</strong></p>
<ul>
<li><p>Stores only file data (not filename or path)</p>
</li>
<li><p>Identical content across files shares one blob</p>
</li>
<li><p>Created during <code>git add</code></p>
</li>
</ul>
<pre><code class="lang-bash">texthello.txt (version 1) → blob abc123
identical.txt         → blob abc123 (shared)
hello.txt (modified)  → blob def456
</code></pre>
<h3 id="heading-tree-directory-structure"><strong>Tree: Directory Structure</strong></h3>
<p>A tree represents a directory and its contents, mapping project structure.</p>
<p><strong>Tree contents:</strong></p>
<ul>
<li><p>File names and permissions</p>
</li>
<li><p>Directory names</p>
</li>
<li><p>References to blobs or child trees</p>
</li>
</ul>
<pre><code class="lang-bash">textproject-root (tree xyz789)
├── src/ (tree uvw123)
│   └── app.component.ts (blob abc123)
└── styles.css (blob def456)
</code></pre>
<h3 id="heading-commit-labeled-project-snapshot"><strong>Commit: Labeled Project Snapshot</strong></h3>
<p>A commit captures a complete project state with metadata.</p>
<p><strong>Commit structure:</strong></p>
<ul>
<li><p>Reference to root tree</p>
</li>
<li><p>Parent commit reference(s)</p>
</li>
<li><p>Author name and timestamp</p>
</li>
<li><p>Commit message</p>
</li>
</ul>
<pre><code class="lang-bash">textCommit feedface (2026-01-10)
├── Tree: xyz789
├── Parent: cafebabe
├── Author: Your Name
└── Message: <span class="hljs-string">"Implement login feature"</span>
</code></pre>
<p>Branches are simply references pointing to commit hashes:</p>
<pre><code class="lang-bash">textrefs/heads/main → feedface
refs/heads/feature → deadbeef
</code></pre>
<h2 id="heading-the-git-add-and-git-commit-workflow"><strong>The</strong> <code>git add</code> and <code>git commit</code> Workflow</h2>
<pre><code class="lang-bash"> Modify app.js
2. git add app.js
   ↓ Creates blob abc123 → .git/objects/12/abc123
   ↓ Updates staging index
3. git commit -m <span class="hljs-string">"Add login feature"</span>
   ↓ Creates tree xyz789 (directory structure)
   ↓ Creates commit feedface (project snapshot)
   ↓ Updates main branch reference
</code></pre>
<p>Commit chain visualization:</p>
<pre><code class="lang-bash">text∅ → commit1(tree1) → commit2(tree2) → main@HEAD(tree3)
</code></pre>
<h2 id="heading-space-efficiency-content-deduplication"><strong>Space Efficiency: Content Deduplication</strong></h2>
<pre><code class="lang-bash">textNaive approach: 1000 commits × 100 files = 100,000 files
Git reality: ~500 unique blobs (incremental changes)
</code></pre>
<p><strong>Deduplication occurs across:</strong></p>
<ul>
<li><p>Unchanged files across commits</p>
</li>
<li><p>Identical files across branches</p>
</li>
<li><p>Duplicate content across projects</p>
</li>
</ul>
<h2 id="heading-content-addressing-with-sha-1-hashes"><strong>Content Addressing with SHA-1 Hashes</strong></h2>
<p>Every Git object uses a 40-character SHA-1 hash derived from its content.</p>
<pre><code class="lang-bash">textIdentical content → Identical <span class="hljs-built_in">hash</span>
Single character change → Completely different <span class="hljs-built_in">hash</span>
</code></pre>
<p><strong>Benefits:</strong></p>
<ul>
<li><p><strong>Integrity:</strong> Tampering invalidates all dependent objects</p>
</li>
<li><p><strong>Deduplication:</strong> Automatic content sharing</p>
</li>
<li><p><strong>Universality:</strong> Object references work across repositories</p>
</li>
</ul>
<h2 id="heading-storage-organization"><strong>Storage Organization</strong></h2>
<pre><code class="lang-bash">text.git/objects/
├── 12/              <span class="hljs-comment"># Objects with hash prefix "12"</span>
│   └── abc123...    <span class="hljs-comment"># app.js blob</span>
├── ab/
│   └── def456...    <span class="hljs-comment"># styles.css blob</span>
└── pack/            <span class="hljs-comment"># Compressed object bundles</span>
</code></pre>
]]></content:encoded></item></channel></rss>