<?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: How It Works]]></title><description><![CDATA[Inside Git: How It Works]]></description><link>https://aniketblog2.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 21 Sep 2026 16:31:41 GMT</lastBuildDate><atom:link href="https://aniketblog2.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
We use git in our day to day life , we use various commands like git add , git commit , git push, etc.
But very few of us know what actually happens internally, Git is used to help track the changes made to the project.
git b...]]></description><link>https://aniketblog2.hashnode.dev/inside-git-how-it-works-and-the-role-of-the-git-folder</link><guid isPermaLink="true">https://aniketblog2.hashnode.dev/inside-git-how-it-works-and-the-role-of-the-git-folder</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[chai-code ]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[Git]]></category><category><![CDATA[commit]]></category><dc:creator><![CDATA[Aniket Saxena]]></dc:creator><pubDate>Sat, 31 Jan 2026 15:27:04 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-how-git-works-internally">How Git Works Internally</h1>
<p>We use git in our day to day life , we use various commands like git add , git commit , git push, etc.</p>
<p>But very few of us know what actually happens internally, Git is used to help track the changes made to the project.</p>
<p>git basically helps us take a screenshot of the file/project whenever we want using the git commit command.</p>
<p>git is like a mini database that saves screenshots of your project.</p>
<p>It has mainly 3 areas:</p>
<p>1.Working Directory — It contains the actual files</p>
<p>2.Staging Area — It contain files that are ready to be saved</p>
<p>3.Repository — Git’s database</p>
<h1 id="heading-understanding-the-git-folder">Understanding the <code>.git</code> Folder</h1>
<p>Whenever we are working on a project , whatever we are doing on it , nothing is getting saved like all the changes we do to it, if we want to go back and look at the previous code we don’t know anything because nobody kept the track of changes , But what if i say there is a way to keep track of all the changes , versions , data and files of the folder , yes There is a way , It is by using the git software.</p>
<p>But a project folder does not use git by default , we first need to do something that will connect our project to git software…..</p>
<p>How do we do it?</p>
<p>We do <strong><em><mark>git init</mark></em></strong></p>
<p>The <strong><em><mark>git init</mark></em></strong> command create a .git/ folder inside the main project folder.</p>
<p>This folder is the brain , memory , database of Git.</p>
<h3 id="heading-structure-of-git-folder"><em>Structure of .git Folder</em></h3>
<p>.git/ Folder contains</p>
<ul>
<li><p>all the data like commits, files and history.</p>
</li>
<li><p>it contains the staging area.</p>
</li>
<li><p>The current branch you’re on (HEAD of the folder)</p>
</li>
<li><p>Branch pointers, etc.</p>
</li>
</ul>
<h1 id="heading-git-objects-blob-tree-commit">Git Objects: Blob, Tree, Commit</h1>
<p>In Git , there are only 3 types of objects - blob , tree and commit.</p>
<h3 id="heading-blob">Blob</h3>
<p>Blob stores the raw data inside a file. It does not store any permissions , file name , etc.</p>
<p>if a file app.js contains — console.log("Hello")</p>
<p>Git will store this text as a git object</p>
<p>If you change this file to — console.log("Hello world")</p>
<p>Git makes a new blob , because every git contains a fingerprint.</p>
<h3 id="heading-tree">Tree</h3>
<p>A tree represents a folder. It contains a folder snapshot.</p>
<p>project/</p>
<p>── app.js → Blob A</p>
<p>── app.css/ → Blob B</p>
<p>—-feat/ —&gt;Tree B</p>
<p><img src="https://git-scm.com/book/ms/v2/images/data-model-1.png" alt="Git - Git Objects" /></p>
<h3 id="heading-commit">Commit</h3>
<p>A commit stores :</p>
<p>-how a project looks</p>
<p>-previous snapshot of project</p>
<p>-author / who did it</p>
<p>-time / when the author did it</p>
<h1 id="heading-how-git-tracks-changes">How Git Tracks Changes</h1>
<p>Git does not track changes like 5 lines changed, etc.</p>
<p>It takes a full snapshot of the current project every time you commit.</p>
<p>So whenever you commit , git takes a full photo of your project</p>
<p>So if git is taking full photo of your project every time would it not waste space??</p>
<p>No IT WON’T</p>
<p>Suppose you have 3 files in your project and you made some changes to one file rest are same ,</p>
<p>Then , initially :</p>
<p>Git stores <strong>3 blobs</strong>:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769871947497/ff398e45-3dd0-4f8b-b2c1-2337c492706d.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-you-change-only-appjs">You change ONLY <code>app.js</code></h3>
<p>Now you commit again.</p>
<p>Git does:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769871960539/95861206-a6fc-4a2f-86e3-cdb8f53a2f0a.png" alt class="image--center mx-auto" /></p>
<p>Git does NOT duplicate unchanged files.</p>
<p>Only changed file = new object.</p>
<h2 id="heading-how-git-detects-a-change">How Git Detects a Change</h2>
<p>Git checks <strong>file content</strong>, not filename.</p>
<p>It calculates a <strong>hash</strong> (fingerprint).</p>
<p>So , Git tracks:</p>
<p>File content<br />Folder structure<br />Snapshots over time</p>
]]></content:encoded></item></channel></rss>