<?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]]></title><description><![CDATA[Inside Git]]></description><link>https://insidegit1deepdrive.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 17 Sep 2026 02:36:14 GMT</lastBuildDate><atom:link href="https://insidegit1deepdrive.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[What is Git?
Git is a Distributed version control system (DVCS) that is used to track every changes in our source code and other files. In simple words, Git help developer by saving the current versions of their work so we can easily look back at pre...]]></description><link>https://insidegit1deepdrive.hashnode.dev/inside-git-how-it-works-and-the-role-of-the-git-folder</link><guid isPermaLink="true">https://insidegit1deepdrive.hashnode.dev/inside-git-how-it-works-and-the-role-of-the-git-folder</guid><category><![CDATA[Git-Internals]]></category><dc:creator><![CDATA[Subhadip dutta]]></dc:creator><pubDate>Sat, 31 Jan 2026 05:32:49 GMT</pubDate><content:encoded><![CDATA[<h2 id="heading-what-is-git">What is Git?</h2>
<p>Git is a Distributed version control system (DVCS) that is used to track every changes in our source code and other files. In simple words, Git help developer by saving the current versions of their work so we can easily look back at previous versions or undo mistakes .Git helps developers collaboratively work with other developers.</p>
<h2 id="heading-what-the-git-folder-is-and-why-it-exists">what the <code>.git</code> folder is and why it exists</h2>
<p>When we run “git init“ , Git creates a hidden directory called .git . The .git folder is Git's database and control center. Every Git repository contains this hidden directory at its root, which stores everything Git needs to track your project's history such as history, commits, branches, tags.</p>
<p>Unlike many systems that track file changes, Git takes a snapshot of your entire project each time you commit. The .git folder stores these snapshots efficiently.</p>
<h2 id="heading-structure-of-the-git-directory">Structure of the <code>.git</code> directory</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769650452235/a683a0d2-1969-47e0-b45b-4c5ad33cd4d7.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-git-objects-blob-tree-commit">Git Objects: Blob, Tree, Commit</h2>
<p>Git stores everything as a object.There are three core object types:-</p>
<p><strong>Blob (Binary Large Object):-</strong></p>
<p>A blob stores the <em>content</em> of a file. It does not store the filename and any metadata. If two files have identical content, Git stores only one blob.</p>
<p>eg:- “Hello World“ → Blob (hash: a1b2c3…..)</p>
<p><strong>Tree:-</strong></p>
<p>It represents a folder.Maps fileNames → blobs or other trees.</p>
<p>Tree</p>
<p>├── index.html → Blob</p>
<p>├── app.js → Blob</p>
<p>└── src/ → Tree</p>
<p><strong>Commit:-</strong></p>
<p>A commit stores:-</p>
<p>i)A reference to a tree (root directory)</p>
<p>ii)A reference to a parent commit.</p>
<p>iii)Author, message, timestamp.</p>
<p>A commit is a snapshot of the entire project, not a diff.</p>
<h2 id="heading-relationship-between-commits-trees-and-blobs">Relationship between commits, trees, and blobs</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769651796628/ffbc3930-9d5c-4d15-9236-84a951497085.png" alt class="image--center mx-auto" /></p>
<p>Think it like this, Blob = file content, Tree = folder Structure, Commit = snapshot + metadata.</p>
<h2 id="heading-how-git-track-changes-the-internal-flow">How git track changes: The internal Flow</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769652314268/66b02824-cc9f-4b77-8434-378190b4a87e.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-what-happens-internally-during-git-add">What Happens Internally During git add</h2>
<p>When we run “git add file.txt“, internally Git does the followings:-</p>
<ol>
<li><p>Reads the content of file.txt</p>
</li>
<li><p>Creates a blob object.</p>
</li>
<li><p>Stores it in .git/objects</p>
</li>
<li><p>Updates the index (staging Area) to point to that blob.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769652807409/a8271c01-59a5-4a57-9c50-d09ffccee964.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-what-happens-internally-during-git-commit">What Happens Internally During git commit</h2>
<p> When we run “git commit -m “message“ “, internally Git does the followings:-</p>
<ol>
<li><p>Reads the index.</p>
</li>
<li><p>Creates tree objects from staged files.</p>
</li>
<li><p>Creates a commit object pointing to the root tree</p>
</li>
<li><p>Moves the branch pointer to the new commit</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769653159842/56ed166f-2bf4-454f-b884-7dc05977dd3e.png" alt class="image--center mx-auto" /></p>
<p> Here nothing is copied—only references are updated.</p>
<h2 id="heading-explain-how-git-uses-hashes-to-ensure-integrity">Explain how Git uses hashes to ensure integrity</h2>
<p> Every Git object is identified by a SHA-1/SHA-256 hash based on object content and object type.</p>
<p> <strong>eg:-</strong> hash = SHA(content + type)</p>
<p> <strong>Why hashes Matter</strong></p>
<p> If content changes → hash changes.</p>
<p> Commits cannot be silently altered.</p>
<p> Entire history is tamper-evident.</p>
</li>
</ol>
</li>
</ol>
<h2 id="heading-mental-model">Mental Model</h2>
<p>    Git stores snapshots of our project, connected by hashes.</p>
<p>    Files = blobs</p>
<p>    Folder = Trees</p>
<p>    Snapshots = commits</p>
<p>    Branches = movable pointer</p>
<p>    “git adds“ stages blobs.</p>
<p>    “git commits“ create trees and commit.</p>
]]></content:encoded></item></channel></rss>