<?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[Role of the .git Folder in your repo]]></title><description><![CDATA[Role of the .git Folder in your repo]]></description><link>https://how-git-works-by-rahul.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 10 Sep 2026 18:20:10 GMT</lastBuildDate><atom:link href="https://how-git-works-by-rahul.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
Git is essentially a persistent map of Keys and Values. Values are your file contents, and the Keys are unique 40-character strings (a SHA-1 hash) generated based on that content. When you save a file in Git, it doesn't care ...]]></description><link>https://how-git-works-by-rahul.hashnode.dev/inside-git-how-it-works-and-the-role-of-the-git-folder</link><guid isPermaLink="true">https://how-git-works-by-rahul.hashnode.dev/inside-git-how-it-works-and-the-role-of-the-git-folder</guid><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Git]]></category><category><![CDATA[How Git Works Internally]]></category><dc:creator><![CDATA[Rahul Ghosh]]></dc:creator><pubDate>Mon, 19 Jan 2026 06:51:13 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1768803156976/5b4b3e89-36a4-47cb-b91a-3ceb93d5c1e8.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-how-git-works-internally">How Git Works Internally</h2>
<p>Git is essentially a persistent map of <em>Keys</em> and <em>Values</em>. Values are your file contents, and the Keys are unique 40-character strings (a SHA-1 hash) generated based on that content. When you save a file in Git, it doesn't care about the filename initially; it only cares about the data. If two files have the same content, Git stores only one copy of that data internally for saving space.</p>
<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 directory called <code>.git</code>. This is where the entire history and "soul" of your project lives. If you delete this folder, your project becomes just a regular set of files with no history.</p>
<p>Key components inside <code>.git</code> folder:</p>
<ul>
<li><p><code>objects/</code>: This stores all your actual file content (blobs), directory structures (trees), and commit metadata. We can say this folder acts like a database.</p>
</li>
<li><p><code>refs/</code>: Stores pointers to commit objects (like where <code>main</code> or <code>feature-x</code> currently point).</p>
</li>
<li><p><code>HEAD</code>: A file that tells Git which branch or commit you are currently working on.</p>
</li>
<li><p><code>index</code>: It’s a binary file that lists what will go into your next commit. Also known as the <strong>Staging Area</strong>.</p>
</li>
</ul>
<h2 id="heading-git-objects-blob-tree-commit">Git Objects: Blob, Tree, Commit</h2>
<p>Everything in the <code>objects/</code> folder falls into one of these three categories: Blob (Binary Large Object),Tree, and Commit.</p>
<ul>
<li><p><strong>Blob (Binary Large Object): →</strong> A Blob stores only the file content. It does not store the filename, the date, or the permissions. For example, if <code>chai-code.txt</code> it contains "Kaise hai ap sabhi", Git hashes "Kaise hai ap sabhi" and stores it as a blob.</p>
</li>
<li><p><strong>Tree: →</strong> A Tree represents a directory. It acts like a list that maps filenames to their corresponding Blobs (for files) or other Trees (for subdirectories). This is where the "filename" information is finally stored.</p>
</li>
<li><p><strong>Commit: →</strong> A Commit is a screenshot of the project at a point in time. It contains:</p>
<ol>
<li><p>A pointer to the <em>root</em> <em>Tree</em> (the top-level folder)</p>
</li>
<li><p>The <em>author</em> and committer information.</p>
</li>
<li><p>A message or a description</p>
</li>
<li><p>A pointer to the <em>parent commit(s)</em>, which creates the <em>chain</em> of history.</p>
</li>
</ol>
</li>
</ul>
<h2 id="heading-how-git-tracks-changes">How Git Tracks Changes?</h2>
<p>Git takes screenshots for tracking the changes.</p>
<ol>
<li><p><strong>Staging: →</strong> When you run <code>git add</code> Git creates a Blob for the file content and updates the <code>index</code> (staging area).</p>
</li>
<li><p><strong>Committing: →</strong> When you run <code>git commit</code>, Git wraps the current <code>index</code> into <em>Tree objects</em> and creates a <em>Commit object</em> that points to that top-level <em>Tree.</em></p>
</li>
<li><p><strong>Efficiency: →</strong> If a file hasn't changed between commit A and commit B, Git does not create a new Blob. The Tree in commit B simply points to the same SHA-1 hash/Blob that commit A used.</p>
</li>
</ol>
]]></content:encoded></item></channel></rss>