<?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 And Role Of .git Folder]]></title><description><![CDATA[Inside Git And Role Of .git Folder]]></description><link>https://inside-git-and-role-of-git-folder.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 23 Sep 2026 19:32:39 GMT</lastBuildDate><atom:link href="https://inside-git-and-role-of-git-folder.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
Hey everyone!In this blog, I will explain how Git works internally in a very simple way. We will understand what the .git folder is, what Git objects are, and how Git tracks changes when we use commands like git add and git c...]]></description><link>https://inside-git-and-role-of-git-folder.hashnode.dev/inside-git-how-it-works-and-the-role-of-the-git-folder</link><guid isPermaLink="true">https://inside-git-and-role-of-git-folder.hashnode.dev/inside-git-how-it-works-and-the-role-of-the-git-folder</guid><category><![CDATA[#Git #.git #VersionControl #GitHub]]></category><dc:creator><![CDATA[Sankalp Pandey]]></dc:creator><pubDate>Tue, 13 Jan 2026 06:42:39 GMT</pubDate><content:encoded><![CDATA[<h2 id="heading-how-git-works-internally">How Git Works Internally</h2>
<p>Hey everyone!<br />In this blog, I will explain how Git works internally in a very simple way. We will understand what the <code>.git</code> folder is, what Git objects are, and how Git tracks changes when we use commands like <code>git add</code> and <code>git commit</code>. This blog is meant to help beginners understand Git conceptually instead of memorizing commands.</p>
<h2 id="heading-what-is-the-git-folder">What is the <code>.git</code> Folder?</h2>
<p>When we initialize a project using the <code>git init</code> command, Git creates a hidden folder called <code>.git</code> inside our project directory.</p>
<p>The <code>.git</code> folder is the heart of Git.<br />It stores all the information related to:</p>
<ul>
<li><p>commits</p>
</li>
<li><p>branches</p>
</li>
<li><p>file changes</p>
</li>
<li><p>project history</p>
</li>
</ul>
<p>Without the <code>.git</code> folder, Git cannot track anything.<br />That is why if we delete the <code>.git</code> folder, the project is no longer a Git repository.</p>
<h2 id="heading-structure-of-the-git-folder">Structure of the <code>.git</code> Folder</h2>
<p>Inside the <code>.git</code> folder, Git stores:</p>
<ul>
<li><p>configuration files</p>
</li>
<li><p>references to branches</p>
</li>
<li><p>objects that store file data and commits</p>
</li>
</ul>
<p>Among these, the objects folder is the most important because Git stores everything as objects.</p>
<h2 id="heading-git-objects-blob-tree-and-commit">Git Objects: Blob, Tree, and Commit</h2>
<p>Git internally stores data in the form of objects. There are mainly three important Git objects:</p>
<h3 id="heading-1-blob-binary-large-object">1. Blob (Binary Large Object)</h3>
<p>A blob stores the content of a file.<br />It does not store the file name, only the data inside the file.</p>
<p>If two files have the same content, Git stores only one blob for both, which helps save space.</p>
<h3 id="heading-2-tree">2. Tree</h3>
<p>A tree represents a directory structure.<br />It stores:</p>
<ul>
<li><p>file names</p>
</li>
<li><p>folder names</p>
</li>
<li><p>references to blobs and other trees</p>
</li>
</ul>
<p>In simple words:</p>
<ul>
<li><p>Blob → file content</p>
</li>
<li><p>Tree → folder structure</p>
</li>
</ul>
<h3 id="heading-3-commit">3. Commit</h3>
<p>A commit object stores:</p>
<ul>
<li><p>reference to a tree</p>
</li>
<li><p>commit message</p>
</li>
<li><p>author details</p>
</li>
<li><p>reference to the previous commit</p>
</li>
</ul>
<p>Each commit represents a snapshot of the project at a specific point in time.</p>
<h2 id="heading-how-git-tracks-changes">How Git Tracks Changes</h2>
<p>Git does not track files like normal systems.<br />Instead, Git tracks snapshots of the project.</p>
<p>When a file changes:</p>
<ul>
<li><p>Git creates a new blob for the updated content</p>
</li>
<li><p>The tree is updated</p>
</li>
<li><p>A new commit points to this new tree</p>
</li>
</ul>
<p>This is how Git keeps the complete history of changes.</p>
<h2 id="heading-what-happens-internally-during-git-add">What Happens Internally During <code>git add</code></h2>
<p>When we run:</p>
<p>→ <code>git add &lt;filename&gt;</code></p>
<p>Internally:</p>
<ul>
<li><p>Git takes the file content</p>
</li>
<li><p>Creates a blob object</p>
</li>
<li><p>Stores it inside the <code>.git/objects</code> directory</p>
</li>
<li><p>Adds the reference to the staging area</p>
</li>
</ul>
<p>At this stage, the changes are not committed, only prepared.</p>
<h2 id="heading-what-happens-internally-during-git-commit">What Happens Internally During <code>git commit</code></h2>
<p>When we run:</p>
<p>→ <code>git commit -m "message"</code></p>
<p>Internally:</p>
<ul>
<li><p>Git creates a tree object from the staged files</p>
</li>
<li><p>Git creates a commit object</p>
</li>
<li><p>The commit points to the tree</p>
</li>
<li><p>Git updates the current branch (HEAD) to this commit</p>
</li>
</ul>
<p>Now the changes are permanently saved in Git history.</p>
<h2 id="heading-how-git-uses-hashes">How Git Uses Hashes</h2>
<p>Git uses hashes (HA-1) to identify objects.<br />Each blob, tree, and commit has a unique hash.</p>
<p>If even a small change happens in a file, the hash changes completely.</p>
<h2 id="heading-finally">Finally</h2>
<p>We know how Git works internally which helps us build a strong mental model of Git. We now know what Git does behind the scenes when we add or commit files.</p>
]]></content:encoded></item></channel></rss>