<?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 and & Role of .git Folder]]></title><description><![CDATA[How Git Works and & Role of .git Folder]]></description><link>https://megawarrior2526.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 01:22:44 GMT</lastBuildDate><atom:link href="https://megawarrior2526.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How GIt Works and the Role of the .git Folder]]></title><description><![CDATA[How Git Works Internally
Git doesn’t store changes the way traditional tools do — it uses a snapshot model: Every time we commit, Git takes a snapshot of the current state of the project. If certain files haven’t changed, Git doesn’t duplicate them —...]]></description><link>https://megawarrior2526.hashnode.dev/how-git-works-and-the-role-of-the-git-folder</link><guid isPermaLink="true">https://megawarrior2526.hashnode.dev/how-git-works-and-the-role-of-the-git-folder</guid><category><![CDATA[#gitwork]]></category><dc:creator><![CDATA[MUDASIR RAZA ATTARI]]></dc:creator><pubDate>Mon, 12 Jan 2026 17:42:43 GMT</pubDate><content:encoded><![CDATA[<h3 id="heading-how-git-works-internally">How Git Works Internally</h3>
<p>Git doesn’t store changes the way traditional tools do — it uses a snapshot model: Every time we commit, Git takes a snapshot of the current state of the project. If certain files haven’t changed, Git doesn’t duplicate them — it references the previous version to save space.</p>
<ul>
<li><p><mark>git add</mark> moves changes from the working directory to the staging area</p>
</li>
<li><p><mark>git commit</mark> captures the staged changes and writes them into the repository.</p>
</li>
</ul>
<p><a target="_blank" href="https://viewer.diagrams.net/?tags=%7B%7D&amp;lightbox=1&amp;highlight=0000ff&amp;edit=_blank&amp;layers=1&amp;nav=1&amp;title=git.drawio&amp;dark=auto#R%3Cmxfile%3E%3Cdiagram%20name%3D%22Page-1%22%20id%3D%22hsM8s74gvIsMSslwcoG1%22%3E7VhL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hv3UwzOB6rN7K6Aj%2FpGTpduLrLRqUKml0tMsyrf99Lg7kzc6g5xeOKcrxn23hnmNA82wzaYOtgMo2XxZ41RL%2F7xcs%2F%2FAw%3D%3D%3C%2Fdiagram%3E%3C%2Fmxfile%3E">Git Diagram</a></p>
<h3 id="heading-understanding-the-git-folder">Understanding the <code>.git</code> Folder</h3>
<p>When we initialize a Git repository <mark>git init </mark> , Git automatically creates a <strong>hidden <mark>.git</mark></strong> <mark> folder</mark>. This folder is the entire guts of your repository — without it, our project has no version history.</p>
<ul>
<li><p>objects/ ……… Stores all Git objects (blobs, trees, commits).</p>
</li>
<li><p>refs/ ………….. Contains pointers to branches and tags.</p>
</li>
<li><p>HEAD ……….. Points to your current branch.</p>
</li>
<li><p>index ………… The staging area.</p>
</li>
<li><p>config/ ……… Repository Settings.</p>
</li>
<li><p>logs/ ………… Stores history of refrences updates</p>
</li>
</ul>
<blockquote>
<p>If you delete <mark>.git</mark> you lose your entire Git history</p>
</blockquote>
<p><a target="_blank" href="https://drive.google.com/file/d/1McUHh5NmDrFNB3uYQ3MRqehwEyj9PBzK/view?usp=sharing">.git diagram</a></p>
<h3 id="heading-git-objects-blob-tree-commit">Git Objects: Blob, Tree, Commit</h3>
<p>Blob — Binary Large Object</p>
<ul>
<li><p>Represents the <strong>contents of a file</strong>.</p>
</li>
<li><p>Stores file data <em>only</em> — no filename or metadata.</p>
</li>
</ul>
<p>Tree — Directory Snapshot</p>
<p>A tree object represents a <strong>directory</strong> — mapping filenames to blobs (files) or other trees (subdirectories)</p>
<p><strong>Commit — Snapshot + History</strong></p>
<p>Each commit snapshot creates a <em>history chain</em> of changes.</p>
<h3 id="heading-how-git-tracks-changes">How Git Tracks Changes</h3>
<p>Git tracks changes by creating new objects only when needed.</p>
<p><mark>Working Directory ↓ git add Staging Area (Index) ↓ git commit Git Repository (.git)</mark></p>
<p>git add</p>
<ul>
<li><p>Takes files from working directory</p>
</li>
<li><p>Creates blob objects (if they changed)</p>
</li>
<li><p>Updates the staging index</p>
</li>
</ul>
<p>git commit</p>
<ul>
<li><p>Takes the staged snapshot</p>
</li>
<li><p>Builds tree objects</p>
</li>
<li><p>Creates a new commit object</p>
</li>
<li><p>Updates <code>HEAD</code> to point to the new commit</p>
</li>
</ul>
]]></content:encoded></item></channel></rss>