<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ishank Gupta</title>
    <description>The latest articles on DEV Community by Ishank Gupta (@ishankg).</description>
    <link>https://dev.to/ishankg</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3476227%2F78f0c610-bfb4-412b-90fe-039741c22e03.jpg</url>
      <title>DEV Community: Ishank Gupta</title>
      <link>https://dev.to/ishankg</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ishankg"/>
    <language>en</language>
    <item>
      <title>Git init: Inside the .git Folder</title>
      <dc:creator>Ishank Gupta</dc:creator>
      <pubDate>Mon, 08 Sep 2025 17:25:48 +0000</pubDate>
      <link>https://dev.to/ishankg/the-secret-life-of-git-init-inside-the-git-folder-21pl</link>
      <guid>https://dev.to/ishankg/the-secret-life-of-git-init-inside-the-git-folder-21pl</guid>
      <description>&lt;p&gt;Hello Fellow Devs 👋,&lt;/p&gt;

&lt;p&gt;Why do we do &lt;code&gt;git init&lt;/code&gt;? Well, to initialize a Git repository, right? Yes, that’s correct — but let’s go a little deeper into what it actually does and why it is required.&lt;/p&gt;

&lt;p&gt;If you’ve read my previous blog where I discussed the layers of Git, you might remember that the core layer of Git is called the persistence layer. This layer is responsible for saving and storing our content (code base). Without it, Git has nowhere to keep our project history.&lt;/p&gt;

&lt;p&gt;So, what exactly happens when we run &lt;code&gt;git init&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ln5fei9cm8vd278ywzp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ln5fei9cm8vd278ywzp.png" alt=" " width="800" height="150"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The &lt;code&gt;.git&lt;/code&gt; Folder&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;When you type &lt;code&gt;git init&lt;/code&gt; Git creates a folder called .git inside your project directory. Inside it, Git sets up a whole directory structure that it will use to track changes, manage versions, and perform all the cool operations we use every day.&lt;/p&gt;

&lt;p&gt;Some of the key parts inside .git are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;objects/&lt;/strong&gt; → where Git stores all your data as objects (commits, trees, and blobs).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;refs/&lt;/strong&gt; → contains references to branches and tags.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HEAD&lt;/strong&gt; → a file that points to your current branch.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;config&lt;/strong&gt; → repository-specific settings.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;index&lt;/strong&gt; → staging area file that keeps track of changes you’ve added.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Objects Folder&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Let’s talk about the &lt;code&gt;objects/&lt;/code&gt; folder because that’s where the magic happens.&lt;/p&gt;

&lt;p&gt;This is the location where all your content is stored, and Git doesn’t just dump files here. Instead, Git uses the SHA-1 hashing algorithm to hash the content and then store it.&lt;/p&gt;

&lt;p&gt;And here’s the important part: Git only cares about the content, not the filename.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The actual content of a file is stored in a data block.&lt;/li&gt;
&lt;li&gt;Git then creates a hash of that content and uses it as a reference.&lt;/li&gt;
&lt;li&gt;Filenames, directory structure, and commits are stored as additional metadata, but the heart of it all is the content hash.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;A Quick Example&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To see how Git thinks, try this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`echo "Hello Git" | git hash-object --stdin`

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’ll get an &lt;strong&gt;SHA-1&lt;/strong&gt; hash as output. That’s basically how Git stores data internally — it converts content into a hash and uses that hash as the identifier.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;👉 Note:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;git hash-object is a plumbing command.&lt;/li&gt;
&lt;li&gt;The | (pipe) takes the output on the left (echo "Hello Git") and feeds it as input to the command on the right (git hash-object).&lt;/li&gt;
&lt;li&gt;The --stdin flag tells Git to read the content directly from standard input.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;That will look something like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjosbp3udgdi25kri9s6y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjosbp3udgdi25kri9s6y.png" alt=" " width="800" height="131"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now here’s something interesting: the content isn’t stored yet. What you just saw is the hash Git would use if it were to save this data. To actually write it into Git’s database, you need to use the &lt;code&gt;-w&lt;/code&gt; flag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo "Hello Git" | git hash-object --stdin -w

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’ll still get the same hash because the content hasn’t changed. But this time, Git writes it into the &lt;code&gt;objects/&lt;/code&gt; folder inside &lt;code&gt;.git&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh9f3nnem15zr0g7yr3go.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh9f3nnem15zr0g7yr3go.png" alt=" " width="800" height="167"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We still get the same hash because the content is the same. If you check your &lt;code&gt;.git/objects&lt;/code&gt; directory now, you’ll see a new folder:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbbdztyljfidz1ibqjq4r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbbdztyljfidz1ibqjq4r.png" alt=" " width="800" height="92"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Inside it, you’ll find a file (something like &lt;code&gt;4d...&lt;/code&gt;) that represents your content. That file isn’t the raw text &lt;code&gt;"Hello Git"&lt;/code&gt; but a compressed object with metadata. Git always stores data this way — hashed, compressed, and referenced.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Final Takeaway&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;So next time you run &lt;code&gt;git init&lt;/code&gt;, remember:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You’re not just “starting a repo.”&lt;/li&gt;
&lt;li&gt;You’re asking Git to set up its database (the &lt;code&gt;.git&lt;/code&gt; folder) where it can store and track everything about your project.&lt;/li&gt;
&lt;li&gt;Without this step, Git has nowhere to save your history.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In short: &lt;code&gt;git init&lt;/code&gt; Lays the foundation for all version control magic that follows. 🚀&lt;/p&gt;

&lt;p&gt;If you found this useful, give it a 👍 and follow along for the next part!&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>devops</category>
    </item>
    <item>
      <title>How Git Works!?</title>
      <dc:creator>Ishank Gupta</dc:creator>
      <pubDate>Tue, 02 Sep 2025 17:15:02 +0000</pubDate>
      <link>https://dev.to/ishankg/how-git-works-c35</link>
      <guid>https://dev.to/ishankg/how-git-works-c35</guid>
      <description>&lt;p&gt;Hello Fellow Devs 👋,&lt;/p&gt;

&lt;p&gt;Have you ever wondered how Git actually works under the hood? Most of us use just a handful of Git commands every day, but Git is far more powerful than git add, git commit, and git push.&lt;/p&gt;

&lt;p&gt;To really understand Git, we need to look at its layers. Why? Because Git isn’t just a collection of commands — it’s a distributed version control system, written in C by Linus Torvalds (the creator of Linux). And like any well-designed software, Git has multiple layers working together.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Learn About Git’s Layers?
&lt;/h2&gt;

&lt;p&gt;Most developers stay at the surface, using Git as a command-line tool to push and pull code. But behind the scenes, Git organizes, stores, and manages data in a very structured way.&lt;/p&gt;

&lt;p&gt;By understanding these layers, you’ll not only know what happens when you type a command, but you’ll also be better prepared to solve tricky Git problems in real projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Four Layers of Git
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fevv8lc1p28zl7xk3jrgd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fevv8lc1p28zl7xk3jrgd.png" alt="Layers Of Git" width="492" height="267"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The persistence layer is what makes Git, well, Git. It stores all of your project’s history in a special hidden folder called .git inside your project directory. This includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Commits&lt;/li&gt;
&lt;li&gt;Branches&lt;/li&gt;
&lt;li&gt;Tags&lt;/li&gt;
&lt;li&gt;Objects (blobs, trees, commits)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Git sets up this &lt;code&gt;.git&lt;/code&gt; folder and initializes its internal file system. From this point on, every change you make can be tracked, committed, and versioned. That folder is your repository—the heart of Git.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;Most developers see Git only as a set of commands, but under the hood, it’s a layered system. By starting with the &lt;strong&gt;persistence layer&lt;/strong&gt;, we can appreciate how Git manages to track everything so reliably.&lt;/p&gt;

&lt;p&gt;In the next post, we’ll uncover how &lt;strong&gt;Git&lt;/strong&gt; uses hashing to uniquely identify everything you store. Don’t miss it 👀&lt;/p&gt;

&lt;p&gt;If you found this useful, give it a 👍 and follow along for the next part!&lt;/p&gt;

</description>
      <category>git</category>
    </item>
  </channel>
</rss>
