<?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[SD-blogs]]></title><description><![CDATA[SD-blogs]]></description><link>https://blog.shubhamdalvi.in</link><generator>RSS for Node</generator><lastBuildDate>Wed, 20 May 2026 06:34:52 GMT</lastBuildDate><atom:link href="https://blog.shubhamdalvi.in/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Shug Accidentally Learned DNS]]></title><description><![CDATA[Shug was just opening a website.
It didn’t load.
He refreshed.Same result.
Chrome showed:

DNS_PROBE_FINISHED_NXDOMAIN

One of those errors that looks serious but explains nothing.
He double-checked the spelling.Internet was fine.Other sites worked.
...]]></description><link>https://blog.shubhamdalvi.in/shug-accidentally-learned-dns</link><guid isPermaLink="true">https://blog.shubhamdalvi.in/shug-accidentally-learned-dns</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><dc:creator><![CDATA[Shubham Dalvi]]></dc:creator><pubDate>Tue, 27 Jan 2026 14:23:35 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769523732092/85e990ba-e951-4c9e-89f7-7907a3f4d40d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Shug was just opening a website.</p>
<p>It didn’t load.</p>
<p>He refreshed.<br />Same result.</p>
<p>Chrome showed:</p>
<blockquote>
<p><strong>DNS_PROBE_FINISHED_NXDOMAIN</strong></p>
</blockquote>
<p>One of those errors that looks serious but explains nothing.</p>
<p>He double-checked the spelling.<br />Internet was fine.<br />Other sites worked.</p>
<p>So why <em>this</em> one?</p>
<p>That’s when Shug realised something obvious, but late.</p>
<p>Browsers don’t understand website names.<br />They understand <strong>numbers</strong>.</p>
<p>You type <a target="_blank" href="http://example.com"><code>example.com</code></a>.<br />The browser needs something like <code>93.184.216.34</code>.</p>
<p>Somewhere in between, that translation has to happen.</p>
<p>That system is DNS.</p>
<h2 id="heading-dns-without-the-complicated-talk">DNS, without the complicated talk</h2>
<p>DNS is basically the <strong>phonebook of the internet</strong>.</p>
<p>You remember names.<br />The internet needs addresses.</p>
<p>Same way you save <em>“Hitesh sir”</em> in your phone instead of memorising his number.</p>
<p>DNS takes a name and finds the correct address behind it.</p>
<p>Simple idea.<br />Lots of small moving parts.</p>
<h2 id="heading-why-dns-has-so-many-records">Why DNS has so many records</h2>
<p>When Shug opened DNS settings, he expected one field.</p>
<p>Instead, he saw a list:<br />A, AAAA, CNAME, MX, TXT, NS.</p>
<p>It felt messy, but it isn’t.</p>
<p>Each record answers a <strong>different question</strong>.</p>
<p>Not everything at once.<br />One question at a time.</p>
<h2 id="heading-ns-record-whos-allowed-to-answer">NS record : who’s allowed to answer?</h2>
<p>Before anything else, the internet asks:</p>
<blockquote>
<p>“Who is responsible for this domain?”</p>
</blockquote>
<p>That answer comes from the <strong>NS record</strong>.</p>
<p>It points to the DNS servers that are in charge of the domain.</p>
<p>When Shug connected his domain to Cloudflare, the NS record told the rest of the internet:</p>
<blockquote>
<p>“Ask Cloudflare about this one.”</p>
</blockquote>
<p>No NS record means no authority.<br />No authority means nothing works.</p>
<h2 id="heading-a-record-where-the-website-lives">A record : where the website lives</h2>
<p>Once authority is clear, the next question is simple:</p>
<blockquote>
<p>“Where is the website?”</p>
</blockquote>
<p>That’s the <strong>A record</strong>.</p>
<p>It maps a domain name to an IPv4 address.</p>
<pre><code class="lang-bash">example.com → 93.184.216.34
</code></pre>
<p>Think of it like this:</p>
<ul>
<li><p>Domain name is the place name</p>
</li>
<li><p>IP address is the exact location</p>
</li>
</ul>
<p>Without an A record, the browser knows <em>what</em> you typed, but not <em>where</em> to go.</p>
<h2 id="heading-aaaa-record-same-idea-newer-address">AAAA record : same idea, newer address</h2>
<p>The <strong>AAAA record</strong> does the same job as A.</p>
<p>The only difference:</p>
<ul>
<li><p>A → IPv4</p>
</li>
<li><p>AAAA → IPv6</p>
</li>
</ul>
<p>IPv6 exists because the internet ran out of IPv4 addresses.</p>
<p>If your hosting supports it, you’ll see AAAA.<br />If not, A still works fine.</p>
<p>No extra philosophy needed.</p>
<h2 id="heading-cname-one-name-pointing-to-another">CNAME — one name pointing to another</h2>
<p>This one confused Shug the first time.</p>
<p>A <strong>CNAME</strong> does <strong>not</strong> point to an IP address.</p>
<p>It points to another <strong>domain name</strong>.</p>
<p>Example:</p>
<pre><code class="lang-bash">www.example.com → example.com
</code></pre>
<p>So when someone opens <a target="_blank" href="http://www.example.com"><code>www.example.com</code></a>, DNS quietly redirects the question to the main domain.</p>
<p>It’s useful for keeping things flexible.</p>
<p>One rule Shug learned the hard way:</p>
<ul>
<li><p>A record → IP address</p>
</li>
<li><p>CNAME → domain name</p>
</li>
</ul>
<p>Mixing them for the same hostname causes problems.</p>
<h2 id="heading-mx-record-why-email-broke">MX record : why email broke</h2>
<p>The website came back.</p>
<p>Emails didn’t.</p>
<p>That’s because email doesn’t use A records.</p>
<p>It uses <strong>MX records</strong>.</p>
<p>When someone sends mail to <a target="_blank" href="mailto:hello@example.com"><code>hello@example.com</code></a>, the internet asks:</p>
<blockquote>
<p>“Which mail server should handle this?”</p>
</blockquote>
<p>MX records answer that.</p>
<p>This is why:</p>
<ul>
<li><p>Website hosting and email hosting are separate</p>
</li>
<li><p>Your site can be on one service and email on another</p>
</li>
</ul>
<p>DNS keeps them organised.</p>
<h2 id="heading-txt-records-proof-not-routing">TXT records : proof, not routing</h2>
<p>TXT records look unimportant.</p>
<p>They aren’t.</p>
<p>They’re mostly used for verification:</p>
<ul>
<li><p>Proving domain ownership</p>
</li>
<li><p>Email security checks</p>
</li>
<li><p>Service integrations</p>
</li>
</ul>
<p>They don’t send traffic anywhere.<br />They just respond when something asks, “Is this legit?”</p>
<p>After breaking email verification once, Shug stopped deleting them.</p>
<h2 id="heading-how-it-all-works-together">How it all works together</h2>
<p>For one normal website:</p>
<ul>
<li><p>NS decides who’s in charge</p>
</li>
<li><p>A / AAAA decides where the site lives</p>
</li>
<li><p>CNAME handles extra names</p>
</li>
<li><p>MX routes email</p>
</li>
<li><p>TXT proves ownership and trust</p>
</li>
</ul>
<p>Each record solves one small problem.</p>
<p>Together, they make the site work.</p>
<h2 id="heading-final-thought">Final thought</h2>
<p>DNS feels confusing until you stop treating it like theory.</p>
<p>Once Shug looked at it as:</p>
<blockquote>
<p>“What question is this record answering?”</p>
</blockquote>
<p>Everything made sense.</p>
<p>The site loaded.<br />Emails started coming in.</p>
<p>Shug finally made chai.</p>
<p>And promised himself not to touch DNS casually again. ☕</p>
]]></content:encoded></item><item><title><![CDATA[Shug Opens the .git Folder]]></title><description><![CDATA[the forbidden folder
shug has been using git for weeks.
git add. git commit. git push.
commands work. project is safe.
but never looked inside .git folder.
uncle mentioned it once: "that's where git keeps everything"
today is the day.
enable hidden f...]]></description><link>https://blog.shubhamdalvi.in/shug-opens-the-git-folder</link><guid isPermaLink="true">https://blog.shubhamdalvi.in/shug-opens-the-git-folder</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[chai-code ]]></category><dc:creator><![CDATA[Shubham Dalvi]]></dc:creator><pubDate>Tue, 13 Jan 2026 09:06:14 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1768290641128/aece11e1-19dd-42f0-8bc0-e7b473d4860f.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-the-forbidden-folder">the forbidden folder</h2>
<p>shug has been using git for weeks.</p>
<p><code>git add</code>. <code>git commit</code>. <code>git push</code>.</p>
<p>commands work. project is safe.</p>
<p>but never looked inside <code>.git</code> folder.</p>
<p>uncle mentioned it once: <em>"that's where git keeps everything"</em></p>
<p>today is the day.</p>
<h2 id="heading-enable-hidden-files">enable hidden files</h2>
<p>shug goes to folder settings.</p>
<p>clicks "show hidden files"</p>
<p>waits.</p>
<p><code>.git</code> folder appears.</p>
<p>shug stares at it.</p>
<p>double clicks.</p>
<p>folder opens.</p>
<p>dramatic music plays in head 🎵</p>
<h2 id="heading-what-lives-inside">what lives inside</h2>
<pre><code class="lang-bash">.git/
├── HEAD
├── config
├── objects/
├── refs/
│   ├── heads/
│   └── tags/
└── ...more stuff
</code></pre>
<p>shug blinks.</p>
<p>weird file names. folders with cryptic names.</p>
<p>no <code>.html</code>. no <code>.css</code>. no normal files.</p>
<p><strong>this is git's brain.</strong></p>
<h2 id="heading-the-objects-folder-memory-vault">the objects folder (memory vault)</h2>
<pre><code class="lang-bash">.git/objects/
</code></pre>
<p>shug clicks into it.</p>
<p>hundreds of folders.</p>
<p>each has 2-character names: <code>a1/</code>, <code>f3/</code>, <code>9e/</code>...</p>
<p>inside each folder: more weird files with long names.</p>
<p>no file extensions.</p>
<p>shug tries to open one in text editor.</p>
<pre><code class="lang-bash">��x�K��OR04f�I��Q����+�...
</code></pre>
<p>gibberish.</p>
<p>closes it quickly.</p>
<p>(feels like opened something not meant for humans)</p>
<p>uncle's voice in head: <em>"objects folder stores everything"</em></p>
<p>okay but... everything as <strong>what</strong>?</p>
<p>shug googles: "git objects folder"</p>
<p>article says: "each file is a git object with SHA-1 hash"</p>
<p>shug: "what's a shaw-one"</p>
<p>more googling.</p>
<p><strong>oh. it's SHA-1. like S-H-A.</strong></p>
<p>hash = fingerprint for data.</p>
<p>same data = same hash.</p>
<p>different data = different hash.</p>
<p>so this folder stores:</p>
<ul>
<li><p>every file shug ever committed</p>
</li>
<li><p>every commit message</p>
</li>
<li><p>every version of every file</p>
</li>
</ul>
<p><strong>all compressed into these weird binary files.</strong></p>
<p>shug stares.</p>
<p>this is git's actual memory.</p>
<p>the brain.</p>
<p>the vault.</p>
<p>everything is here.</p>
<p>nothing is ever truly deleted.</p>
<p>shug feels weird about it.</p>
<p><em>my entire project history is in this one folder?</em></p>
<p>checks folder size: 4.2 MB</p>
<p>project is 50 MB.</p>
<p>how?</p>
<p>git compression magic.</p>
<p>(uncle will explain later)</p>
<p>for now shug just knows:</p>
<p><code>.git/objects/</code> = where git remembers everything.</p>
<p>touch this folder = break git.</p>
<p>respect this folder = git respects you.</p>
<p>shug closes it gently.</p>
<p><strong>like closing someone's diary.</strong></p>
<h2 id="heading-reading-a-commit-object">reading a commit object</h2>
<p>okay but can shug actually <strong>read</strong> these things?</p>
<p>googles again: "how to read git objects"</p>
<p>finds command: <code>git cat-file</code></p>
<p>uncle mentioned this once.</p>
<p>time to try.</p>
<p><strong>first</strong>: get a commit hash.</p>
<pre><code class="lang-bash">git <span class="hljs-built_in">log</span> --oneline
</code></pre>
<p><strong>output</strong>:</p>
<pre><code class="lang-bash">a1b2c3d updated heading
e4f5g6h fixed typo
7h8i9j0 initial commit
</code></pre>
<p>okay. <code>a1b2c3d</code> is latest commit.</p>
<p>now the scary command:</p>
<pre><code class="lang-bash">git cat-file -p a1b2c3d
</code></pre>
<p>shug hits enter.</p>
<p>holds breath.</p>
<p><strong>output</strong>:</p>
<pre><code class="lang-bash">tree 4f8e9a1
parent e4f5g6h
author shug &lt;shug@email.com&gt;
committer shug &lt;shug@email.com&gt;
date: Mon Jan 8 14:23:11 2024

updated heading
</code></pre>
<p><strong>shug stares.</strong></p>
<p>it worked?</p>
<p>it just... showed the commit?</p>
<p>reads it again.</p>
<p><strong>commit has structure:</strong></p>
<ul>
<li><p><code>tree 4f8e9a1</code> → project snapshot at this moment</p>
</li>
<li><p><code>parent e4f5g6h</code> → previous commit (the one before this)</p>
</li>
<li><p><code>author</code> → who made it (me)</p>
</li>
<li><p><code>committer</code> → who committed it (also me)</p>
</li>
<li><p><code>date</code> → when</p>
</li>
<li><p><code>updated heading</code> → commit message (why)</p>
</li>
</ul>
<p>shug tries something.</p>
<p>what if checks the <strong>parent</strong> commit?</p>
<pre><code class="lang-bash">git cat-file -p e4f5g6h
</code></pre>
<p>output:</p>
<pre><code class="lang-bash">tree 2c3d4e5
parent 7h8i9j0
author shug &lt;shug@email.com&gt;

fixed typo
</code></pre>
<p>it has a parent too.</p>
<p>which also has a parent.</p>
<p><strong>wait.</strong></p>
<p><em>it's a chain.</em></p>
<p>shug's brain clicks.</p>
<p>every commit points to its parent.</p>
<p>git follows these pointers backward.</p>
<p>that's how <code>git log</code> works.</p>
<p>that's how history exists.</p>
<p><strong>mind blown.</strong> 🤯</p>
<p>sits back in chair.</p>
<p>stares at ceiling.</p>
<p>git isn't magic.</p>
<p>it's just... linked data.</p>
<p>like a playlist where each song remembers the previous song.</p>
<p>tries one more thing:</p>
<pre><code class="lang-bash">git cat-file -p 4f8e9a1
</code></pre>
<p>(that's the tree hash from first commit)</p>
<p><strong>output</strong>:</p>
<pre><code class="lang-bash">100644 blob 8ab3f21    index.html
100644 blob f39d8e2    style.css
040000 tree a84d9c1    images/
</code></pre>
<p><strong>the tree shows files in that commit.</strong></p>
<p>each file has its own hash (blob).</p>
<p>shug checks a blob:</p>
<pre><code class="lang-bash">git cat-file -p 8ab3f21
</code></pre>
<p>output:</p>
<pre><code class="lang-html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>shug's project<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
</code></pre>
<p><strong>it's the actual file content.</strong></p>
<p>shug leans back.</p>
<p>closes laptop.</p>
<p>needs a moment.</p>
<p><strong>the whole system just made sense:</strong></p>
<ol>
<li><p>you commit → git creates snapshot</p>
</li>
<li><p>snapshot = tree object listing all files</p>
</li>
<li><p>each file = blob object with content</p>
</li>
<li><p>commit points to tree + parent commit</p>
</li>
<li><p>git walks these links for history</p>
</li>
</ol>
<p><strong>opens laptop again.</strong></p>
<p>one more test.</p>
<p>creates new file. commits it.</p>
<p>checks <code>.git/objects/</code> folder.</p>
<p><strong>new folders appeared.</strong></p>
<p>new hashes.</p>
<p>for new commit. new tree. new blob.</p>
<p>everything is stored.</p>
<p>everything is linked.</p>
<p><strong>git is just a graph database.</strong></p>
<p>shug messages uncle:</p>
<p>"i get it now"</p>
<p>uncle: "get what"</p>
<p>"commits are linked lists"</p>
<p>uncle: "🎉"</p>
<p>raj messages same time:</p>
<p>"git push not working again"</p>
<p>shug screenshots the <code>git cat-file</code> output.</p>
<p>sends to raj.</p>
<p>raj: "what is this"</p>
<p>shug: "your future"</p>
<p>leaves him on read.</p>
<p><strong>some people aren't ready.</strong></p>
<h2 id="heading-commits-are-linked-the-chain">commits are linked (the chain)</h2>
<p>shug draws this on paper:</p>
<pre><code class="lang-bash">commit 01 ← commit 02 ← commit 03
                          ↑
                        HEAD
</code></pre>
<p>each arrow is a parent pointer.</p>
<p>git walks backward through parents.</p>
<p>this creates complete history.</p>
<p>shug finally understands <code>git log</code>.</p>
<p>it's not magic.</p>
<p>git starts at HEAD.</p>
<p>reads current commit.</p>
<p>checks parent. reads that.</p>
<p>checks parent. reads that.</p>
<p>keeps going until no more parents.</p>
<p><strong>that's the log.</strong></p>
<p>simple.</p>
<h2 id="heading-head-your-position-marker">HEAD: your position marker</h2>
<pre><code class="lang-bash">.git/HEAD
</code></pre>
<p>shug opens this file in text editor:</p>
<pre><code class="lang-bash">ref: refs/heads/main
</code></pre>
<p>one line. that's it.</p>
<p>HEAD points to current branch.</p>
<p>branch points to latest commit.</p>
<p>shug thinks: "so HEAD is like... my cursor in history?"</p>
<p>yes. exactly that.</p>
<p><strong>HEAD = "you are here" marker</strong></p>
<p>make new commit → HEAD moves forward</p>
<p>checkout old commit → HEAD moves backward</p>
<p>tries something:</p>
<pre><code class="lang-bash">git checkout e4f5g6h
</code></pre>
<p>(checking out old commit directly)</p>
<p>warning message appears:</p>
<pre><code class="lang-bash">You are <span class="hljs-keyword">in</span> <span class="hljs-string">'detached HEAD'</span> state...
</code></pre>
<p>shug panics.</p>
<p>googles "detached head git"</p>
<p><strong>oh. HEAD just moved off the branch.</strong></p>
<p>now points directly to commit instead of branch name.</p>
<p>not broken. just... floating.</p>
<pre><code class="lang-bash">git checkout main
</code></pre>
<p>HEAD reattaches.</p>
<p>crisis averted.</p>
<h2 id="heading-the-bug-scenario-shugs-nightmare-returns">the bug scenario (shug's nightmare returns)</h2>
<p>remember episode 1?</p>
<p>shug committed bug. broke entire project.</p>
<p>had to rewrite everything from memory.</p>
<p><strong>never again.</strong></p>
<p><strong>scenario</strong>:</p>
<p>shug commits bug in commit 03.</p>
<p>realizes 2 commits later at commit 05.</p>
<p>panic mode activated.</p>
<p>but wait.</p>
<p><em>shug knows git now.</em></p>
<h3 id="heading-option-1-revert-the-safe-way">option 1: revert (the safe way)</h3>
<pre><code class="lang-bash">git revert 03
</code></pre>
<p>shug tries it.</p>
<p>git opens editor.</p>
<p>asks for commit message.</p>
<p>shug types: "reverting the bug commit"</p>
<p>saves.</p>
<p>done.</p>
<p>checks <code>git log</code>:</p>
<pre><code class="lang-bash">01 ← 02 ← 03 ← 04 ← 05 ← 06 (revert of 03)
                              ↑
                            HEAD
</code></pre>
<p>commit 03 still exists in history.</p>
<p>but commit 06 undoes its changes.</p>
<p>bug is gone.</p>
<p>history is preserved.</p>
<p><strong>team can see what happened.</strong></p>
<p>safe. reversible. professional.</p>
<h3 id="heading-option-2-reset-the-dangerous-way">option 2: reset (the dangerous way)</h3>
<p>shug reads about another option.</p>
<p><code>git reset --hard</code></p>
<p><em>"use with caution"</em> every article says.</p>
<p>shug creates test branch to try it.</p>
<pre><code class="lang-bash">git reset --hard 02
</code></pre>
<p><strong>poof.</strong></p>
<p>commits 03, 04, 05 disappear from <code>git log</code>.</p>
<pre><code class="lang-bash">01 ← 02
      ↑
    HEAD

(03, 04, 05 are gone)
</code></pre>
<p>checks working directory.</p>
<p>files reverted to commit 02 state.</p>
<p>all changes after that: deleted.</p>
<p>shug's heart races.</p>
<p>this is powerful.</p>
<p>but dangerous.</p>
<p><strong>what if already pushed to team?</strong></p>
<p>now their history has commits that yours doesn't.</p>
<p>merge conflicts from hell.</p>
<p>quickly undoes test:</p>
<pre><code class="lang-bash">git reflog
</code></pre>
<p>(shows all HEAD movements, even deleted commits)</p>
<p>finds deleted commit hash.</p>
<pre><code class="lang-bash">git reset --hard a1b2c3d
</code></pre>
<p><strong>commits are back.</strong></p>
<p>breathes again.</p>
<p><strong>lesson learned:</strong></p>
<p><code>git revert</code> = safe for shared branches</p>
<p><code>git reset --hard</code> = only for local mistakes</p>
<p>never reset shared history.</p>
<p>shug writes this on sticky note.</p>
<p>sticks to monitor.</p>
<h2 id="heading-branches-revealed-biggest-surprise">branches revealed (biggest surprise)</h2>
<p>shug always thought branch = copy of code.</p>
<p>like:</p>
<ul>
<li><p><code>main</code> folder with all files</p>
</li>
<li><p><code>feature</code> folder with all files copied</p>
</li>
</ul>
<p>heavy. slow. duplicate everything.</p>
<p><strong>wrong.</strong></p>
<p>goes to:</p>
<pre><code class="lang-bash">.git/refs/heads/main
</code></pre>
<p>opens file.</p>
<pre><code class="lang-bash">a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0
</code></pre>
<p><strong>one line.</strong></p>
<p>just a commit hash.</p>
<p>that's it.</p>
<p><strong>branch = pointer to commit.</strong></p>
<p>nothing more.</p>
<p>no copied files.</p>
<p>no duplicate data.</p>
<p>just a named pointer.</p>
<p>shug stands up.</p>
<p>sits back down.</p>
<p>opens <code>feature</code> branch file:</p>
<pre><code class="lang-bash">.git/refs/heads/feature
</code></pre>
<p>inside:</p>
<pre><code class="lang-bash">x1y2z3a4b5c6d7e8f9g0h1i2j3k4l5m6n7o8p9q0
</code></pre>
<p>different hash.</p>
<p><strong>different pointer.</strong></p>
<p>that's the only difference between branches.</p>
<p><em>years of confusion solved in one folder.</em></p>
<h2 id="heading-creating-branch-what-really-happens">creating branch (what really happens)</h2>
<p>shug tests this theory.</p>
<pre><code class="lang-bash">git checkout -b test-branch
</code></pre>
<p>output:</p>
<pre><code class="lang-bash">Switched to a new branch <span class="hljs-string">'test-branch'</span>
</code></pre>
<p>checks <code>.git/refs/heads/</code>:</p>
<p><strong>new file appeared:</strong> <code>test-branch</code></p>
<p>inside: same commit hash as <code>main</code>.</p>
<p>because created from <code>main</code>.</p>
<p>both point to same commit initially.</p>
<p>makes one commit on <code>test-branch</code>.</p>
<p>checks file again:</p>
<p><strong>hash changed.</strong></p>
<p>now points to new commit.</p>
<p><code>main</code> still points to old commit.</p>
<pre><code class="lang-bash">      main
       ↓
01 ← 02
       ↖
         03 ← test-branch
</code></pre>
<p>no duplication.</p>
<p>no copying.</p>
<p>just pointers moving.</p>
<p><strong>brilliant.</strong></p>
<p>shug deletes <code>test-branch</code>:</p>
<pre><code class="lang-bash">git branch -d test-branch
</code></pre>
<p>checks <code>.git/refs/heads/</code>:</p>
<p><strong>file is gone.</strong></p>
<p>that's all deleting a branch does.</p>
<p>removes the pointer file.</p>
<p>commit 03 still exists in objects folder.</p>
<p>just not pointed to by any branch.</p>
<p>(will be garbage collected eventually)</p>
<h2 id="heading-the-snapshot-insight">the snapshot insight</h2>
<p>shug reads more about git internals.</p>
<p>article says something weird:</p>
<p><strong>"git doesn't track changes. it tracks snapshots."</strong></p>
<p>reads that again.</p>
<p>what?</p>
<p>every commit = complete picture of project.</p>
<p>not "changed line 12 in file.css"</p>
<p>but "here's entire project at this moment"</p>
<p>shug tests:</p>
<p>changes one line in <code>style.css</code>.</p>
<p>commits.</p>
<pre><code class="lang-bash">git show HEAD
</code></pre>
<p>output shows:</p>
<pre><code class="lang-diff"><span class="hljs-deletion">- color: blue;</span>
<span class="hljs-addition">+ color: red;</span>
</code></pre>
<p>but internally?</p>
<p>git stored <strong>entire new version</strong> of <code>style.css</code>.</p>
<p>compared both versions.</p>
<p>showed difference.</p>
<p><strong>why do this?</strong></p>
<p>because comparing two snapshots is fast.</p>
<p>tracking individual changes is slow and complex.</p>
<p>snapshots are simple.</p>
<p>git optimizes storage with compression.</p>
<p>but concept is: full snapshots.</p>
<p>shug's mental model updates:</p>
<p>commits aren't deltas.</p>
<p>commits are photographs.</p>
<p>git album of project over time.</p>
<h2 id="heading-config-file-repository-settings">config file (repository settings)</h2>
<pre><code class="lang-bash">.git/config
</code></pre>
<p>shug opens it:</p>
<pre><code class="lang-ini"><span class="hljs-section">[core]</span>
    <span class="hljs-attr">repositoryformatversion</span> = <span class="hljs-number">0</span>
    <span class="hljs-attr">filemode</span> = <span class="hljs-literal">true</span>
    <span class="hljs-attr">bare</span> = <span class="hljs-literal">false</span>
<span class="hljs-section">[remote "origin"]</span>
    <span class="hljs-attr">url</span> = https://github.com/shug/project.git
    <span class="hljs-attr">fetch</span> = +refs/heads/*:refs/remotes/origin/*
<span class="hljs-section">[branch "main"]</span>
    <span class="hljs-attr">remote</span> = origin
    <span class="hljs-attr">merge</span> = refs/heads/main
</code></pre>
<p><strong>readable. editable. just text.</strong></p>
<p>this stores:</p>
<ul>
<li><p>remote repository url (github)</p>
</li>
<li><p>branch tracking info</p>
</li>
<li><p>user preferences</p>
</li>
<li><p>repository settings</p>
</li>
</ul>
<p>can edit manually.</p>
<p>or use commands:</p>
<pre><code class="lang-bash">git config user.name <span class="hljs-string">"shug"</span>
git config user.email <span class="hljs-string">"shug@email.com"</span>
</code></pre>
<p>both work.</p>
<p>config file updates either way.</p>
<p>shug changes email:</p>
<pre><code class="lang-bash">git config user.email <span class="hljs-string">"shug@newmail.com"</span>
</code></pre>
<p>checks config file:</p>
<pre><code class="lang-ini"><span class="hljs-section">[user]</span>
    <span class="hljs-attr">email</span> = shug@newmail.com
</code></pre>
<p><strong>appeared at bottom.</strong></p>
<p>all git config lives here.</p>
<p>no hidden database.</p>
<p>just text file.</p>
<h2 id="heading-everything-connects">everything connects</h2>
<p>shug draws final mental map on whiteboard:</p>
<p><strong>1. working directory</strong> → where you edit files</p>
<p><strong>2. staging area</strong> → temporary selection (<code>git add</code>)</p>
<p><strong>3. repository</strong> → permanent history (<code>git commit</code>)</p>
<p><strong>4. objects folder</strong> → where data actually lives</p>
<p><strong>5. HEAD</strong> → current position marker</p>
<p><strong>6. branches</strong> → named pointers to commits</p>
<p><strong>7. commits</strong> → linked snapshots with parent pointers</p>
<p>arrows between everything.</p>
<p>the system makes sense now.</p>
<p>not magic.</p>
<p>just clever file organization.</p>
<h2 id="heading-the-transformation">the transformation</h2>
<p>shug opens old notes from episode 1.</p>
<p><strong>before:</strong></p>
<ul>
<li><p>copied commands from stackoverflow</p>
</li>
<li><p>git was black box</p>
</li>
<li><p>feared every operation</p>
</li>
<li><p>"what if i break something"</p>
</li>
<li><p>"why didn't it work"</p>
</li>
<li><p>panic when errors appeared</p>
</li>
</ul>
<p><strong>after:</strong></p>
<ul>
<li><p>understands what commands do</p>
</li>
<li><p>can predict git behavior</p>
</li>
<li><p>reads error messages and knows why</p>
</li>
<li><p>"oh, HEAD is detached, just checkout main"</p>
</li>
<li><p>"revert instead of reset for shared branch"</p>
</li>
<li><p>confidence in daily workflow</p>
</li>
</ul>
<p>the difference isn't commands memorized.</p>
<p>the difference is <strong>mental model.</strong></p>
<p>shug knows what's happening inside <code>.git</code>.</p>
<p>commands make sense now.</p>
<h2 id="heading-shugs-new-powers">shug's new powers</h2>
<p>now shug can:</p>
<ul>
<li><p>recover deleted code ✅ (<code>git reflog</code>)</p>
</li>
<li><p>track who changed what ✅ (<code>git log</code>)</p>
</li>
<li><p>rollback to any point ✅ (<code>git revert</code> or <code>git reset</code>)</p>
</li>
<li><p>work on features safely ✅ (branches are just pointers)</p>
</li>
<li><p>collaborate without chaos ✅ (understanding merge/push)</p>
</li>
<li><p>sleep peacefully ✅ (everything is stored)</p>
</li>
</ul>
<p>the pendrive trauma is healed.</p>
<h2 id="heading-final-realization">final realization</h2>
<p>shug closes laptop.</p>
<p>leans back.</p>
<p>thinks about the journey.</p>
<p>git exists because humans:</p>
<ul>
<li><p>forget things</p>
</li>
<li><p>make mistakes</p>
</li>
<li><p>need history</p>
</li>
<li><p>collaborate badly</p>
</li>
<li><p>overwrite each other's work</p>
</li>
<li><p>lose files</p>
</li>
</ul>
<p>git remembers so you don't have to.</p>
<p><code>.git</code> folder is safety net.</p>
<p>commits are checkpoints.</p>
<p>branches are parallel universes.</p>
<p>HEAD is your position.</p>
<p><strong>shug respects git now.</strong> 🧠✨</p>
<p>not just tool.</p>
<p>but philosophy.</p>
<p>version everything.</p>
<p>commit often.</p>
<p>history is freedom.</p>
<h2 id="heading-what-shug-learned-throughout-the-journey">what shug learned throughout the journey</h2>
<h3 id="heading-episode-1-the-problem">episode 1: the problem</h3>
<ul>
<li><p>collaboration without version control = chaos</p>
</li>
<li><p>pendrives and email don't scale</p>
</li>
<li><p>manually tracking versions fails</p>
</li>
<li><p>humans need automatic memory</p>
</li>
<li><p>git solves this</p>
</li>
</ul>
<h3 id="heading-episode-2-the-basics">episode 2: the basics</h3>
<ul>
<li><p>git tracks changes locally</p>
</li>
<li><p>three-stage workflow: edit → stage → commit</p>
</li>
<li><p>basic commands for daily work</p>
</li>
<li><p>github for remote backup</p>
</li>
<li><p>never lose work again</p>
</li>
</ul>
<h3 id="heading-episode-3-the-internals">episode 3: the internals</h3>
<ul>
<li><p>everything lives in <code>.git</code> folder</p>
</li>
<li><p>objects folder stores all data</p>
</li>
<li><p>commits are linked snapshots</p>
</li>
<li><p>branches are just pointers</p>
</li>
<li><p>HEAD tracks position</p>
</li>
<li><p>git is simple system, not magic</p>
</li>
</ul>
<h2 id="heading-three-weeks-later">three weeks later</h2>
<p>shug helps coworker with git issue.</p>
<p>coworker: "git says detached HEAD, what do i do?"</p>
<p>shug: "checkout your branch name"</p>
<p>coworker: "how did you know?"</p>
<p>shug shrugs: "just know how HEAD works"</p>
<p>explains pointers and commits.</p>
<p>coworker stares.</p>
<p><strong>"you're really good at this"</strong></p>
<p>shug thinks back to episode 1.</p>
<p>remembers crying over lost pendrive.</p>
<p>remembers raj's smug face.</p>
<p>remembers uncle's patience.</p>
<p><strong>look at me now.</strong></p>
<h2 id="heading-the-end">the end</h2>
<p>raj texts: "can you help with my git"</p>
<p>shug: "did you read the docs?"</p>
<p>raj: "too long"</p>
<p>shug: "then suffer"</p>
<p><strong>some people never learn.</strong></p>
<p>but shug did.</p>
<p>and now?</p>
<p>git is second nature.</p>
<p><code>.git</code> folder is old friend.</p>
<p>commits flow naturally.</p>
<p><strong>shug conquered git.</strong></p>
<p><strong>(and raj? still emails zip files.</strong> 😤)</p>
<h3 id="heading-to-be-continued">to be continued?</h3>
<p>shug still has questions:</p>
<ul>
<li><p>merge conflicts (when history diverges)</p>
</li>
<li><p>rebasing (rewriting history cleanly)</p>
</li>
<li><p>advanced workflows (git flow, trunk-based)</p>
</li>
</ul>
<p>but that's for another day.</p>
<p>for now, fundamentals are solid.</p>
<p><strong>and that's enough.</strong></p>
<p><em>shug will sleep happily now after sipping his hot cup of chai.</em></p>
]]></content:encoded></item><item><title><![CDATA[Shug Meets Git (And Gets Confused Immediately)]]></title><description><![CDATA[the tutorial trap
shug opens youtube.
searches: "git tutorial for beginners"
watches 45 minute video.
learns commands:
git init
git add .
git commit -m "initial commit"
git push origin main

shug copies commands.
everything works.
but shug has no ide...]]></description><link>https://blog.shubhamdalvi.in/shug-meets-git-and-gets-confused-immediately</link><guid isPermaLink="true">https://blog.shubhamdalvi.in/shug-meets-git-and-gets-confused-immediately</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><dc:creator><![CDATA[Shubham Dalvi]]></dc:creator><pubDate>Sun, 04 Jan 2026 09:20:41 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1767514437568/4593fc56-4f6b-4fb4-8ab3-877ff50bc478.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-the-tutorial-trap">the tutorial trap</h2>
<p>shug opens youtube.</p>
<p>searches: <strong>"git tutorial for beginners"</strong></p>
<p>watches 45 minute video.</p>
<p>learns commands:</p>
<pre><code class="lang-bash">git init
git add .
git commit -m <span class="hljs-string">"initial commit"</span>
git push origin main
</code></pre>
<p>shug copies commands.</p>
<p>everything works.</p>
<p><strong>but shug has no idea what just happened.</strong></p>
<h2 id="heading-repeat-after-me-syndrome">repeat after me syndrome</h2>
<p>for next 3 months, shug's workflow:</p>
<ol>
<li><p>google "how to push code to github"</p>
</li>
<li><p>copy paste commands</p>
</li>
<li><p>hope it works</p>
</li>
<li><p>it works</p>
</li>
<li><p>still no understanding</p>
</li>
</ol>
<p>shug becomes copy paste developer.</p>
<h2 id="heading-the-breaking-point">the breaking point</h2>
<p>one day shug's teammate asks:</p>
<blockquote>
<p>"can you merge my branch?"</p>
</blockquote>
<p><strong>shug:</strong> "what is branch?"</p>
<p><strong>teammate:</strong> "you don't know branches?"</p>
<p><strong>shug:</strong> "i know <code>git push</code>"</p>
<p><strong>teammate:</strong> 😐</p>
<p>time to actually learn.</p>
<h2 id="heading-what-git-actually-is">what git actually is</h2>
<p>shug sits down.</p>
<p>reads carefully.</p>
<p><strong>git = version control system</strong></p>
<p>okay but what does that mean in real terms?</p>
<p>git is tool that:</p>
<ul>
<li><p>tracks changes in your code</p>
</li>
<li><p>stores complete history</p>
</li>
<li><p>works locally on your computer</p>
</li>
<li><p>doesn't need internet</p>
</li>
</ul>
<h2 id="heading-git-vs-github-shug-was-confused">git vs github (shug was confused)</h2>
<p>shug thought git = github.</p>
<p>wrong.</p>
<p><strong>git</strong> → software on your computer (the brain 🧠)<br /><strong>github</strong> → website that stores git projects (the cloud ☁️)</p>
<p>analogy:</p>
<ul>
<li><p>git = your brain keeping memories</p>
</li>
<li><p>github = google photos backup</p>
</li>
</ul>
<p>git works without github.<br />github is useless without git.</p>
<p>mind blown 🤯</p>
<h2 id="heading-the-git-folder-revelation">the <code>.git</code> folder revelation</h2>
<p>shug types first real command:</p>
<pre><code class="lang-bash">git init
</code></pre>
<p>nothing visible happens.</p>
<p>but shug checks folder.</p>
<p><strong>hidden folder appears:</strong> <code>.git</code></p>
<p>this is where everything lives.</p>
<p>all history.<br />all commits.<br />all branches.<br />all memory.</p>
<p><strong>delete this folder → git forgets everything</strong></p>
<p>shug stares at <code>.git</code> folder with respect.</p>
<h2 id="heading-how-git-remembers-the-actual-flow">how git remembers (the actual flow)</h2>
<p>shug draws diagram in notebook:</p>
<pre><code class="lang-plaintext">working directory
      ↓
  git add
      ↓
staging area
      ↓
  git commit
      ↓
.git folder (permanent storage)
</code></pre>
<h3 id="heading-step-1-working-directory">step 1: working directory</h3>
<p>shug edits <code>index.html</code>:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>hello world<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
</code></pre>
<p>git notices change.<br />but does nothing yet.</p>
<p>shug checks:</p>
<pre><code class="lang-bash">git status
</code></pre>
<p>output:</p>
<pre><code class="lang-plaintext">modified: index.html
</code></pre>
<p>git is watching.</p>
<h3 id="heading-step-2-staging-area-the-waiting-room">step 2: staging area (the waiting room)</h3>
<pre><code class="lang-bash">git add index.html
</code></pre>
<p>change moves to staging area.</p>
<p>staging = <strong>"i want to remember this change"</strong></p>
<p>git status now shows:</p>
<pre><code class="lang-plaintext">Changes to be committed:
  modified: index.html
</code></pre>
<p>still not permanent.</p>
<p>shug can unstage if needed.</p>
<h3 id="heading-step-3-commit-permanent-memory">step 3: commit (permanent memory)</h3>
<pre><code class="lang-bash">git commit -m <span class="hljs-string">"added hello world heading"</span>
</code></pre>
<p>now git saves it forever.</p>
<p>commit stores:</p>
<ul>
<li><p>what changed (diff)</p>
</li>
<li><p>who changed it (shug)</p>
</li>
<li><p>when it changed (timestamp)</p>
</li>
<li><p>why it changed (commit message)</p>
</li>
</ul>
<p>this snapshot is now permanent.</p>
<p>even if shug deletes file later, git remembers.</p>
<h2 id="heading-the-commands-shug-actually-uses">the commands shug actually uses</h2>
<h3 id="heading-seeing-what-changed">seeing what changed</h3>
<pre><code class="lang-bash">git status
</code></pre>
<p>shows current state.</p>
<h3 id="heading-seeing-history">seeing history</h3>
<pre><code class="lang-bash">git <span class="hljs-built_in">log</span>
</code></pre>
<p>shows all commits.</p>
<p>better version:</p>
<pre><code class="lang-bash">git <span class="hljs-built_in">log</span> --oneline
</code></pre>
<p>cleaner output.</p>
<h3 id="heading-seeing-specific-changes">seeing specific changes</h3>
<pre><code class="lang-bash">git diff
</code></pre>
<p>shows line-by-line changes before staging.</p>
<h2 id="heading-shugs-first-real-workflow">shug's first real workflow</h2>
<p><strong>day 1:</strong> shug creates project</p>
<pre><code class="lang-bash">mkdir my-project
<span class="hljs-built_in">cd</span> my-project
git init
</code></pre>
<p>git is now watching this folder.</p>
<p><strong>day 2:</strong> shug adds files</p>
<pre><code class="lang-bash">touch index.html
git add index.html
git commit -m <span class="hljs-string">"added index file"</span>
</code></pre>
<p>first commit created ✅</p>
<p><strong>day 3:</strong> shug makes changes</p>
<p>edits <code>index.html</code></p>
<pre><code class="lang-bash">git add index.html
git commit -m <span class="hljs-string">"updated heading"</span>
</code></pre>
<p>second commit created ✅</p>
<p><strong>day 4:</strong> shug checks history</p>
<pre><code class="lang-bash">git <span class="hljs-built_in">log</span> --oneline
</code></pre>
<p>output:</p>
<pre><code class="lang-plaintext">a1b2c3d updated heading
e4f5g6h added index file
</code></pre>
<p><strong>shug can see everything that happened</strong></p>
<p>no more mystery.<br />no more "when did i change this?"</p>
<h2 id="heading-the-realization-moment">the realization moment</h2>
<p>shug accidentally deletes entire file.</p>
<p>panics.</p>
<p>then remembers: git has history.</p>
<pre><code class="lang-bash">git checkout HEAD index.html
</code></pre>
<p>file comes back.</p>
<p><strong>shug's hands stop shaking.</strong></p>
<p>this is why git exists.</p>
<h2 id="heading-but-questions-remain">but questions remain</h2>
<p>shug understands commands now.</p>
<p>but still confused about:</p>
<ul>
<li><p>where is git storing all this data?</p>
</li>
<li><p>what is HEAD?</p>
</li>
<li><p>how do commits connect?</p>
</li>
<li><p>what are branches actually?</p>
</li>
</ul>
<p>time to look inside.</p>
<p>🎬 <em>continue to episode 3</em></p>
]]></content:encoded></item><item><title><![CDATA[Shug’s Pendrive Disaster: Why Git Exists]]></title><description><![CDATA[the year: 2018
shug is final year student.
project deadline: 2 days
team size: 4 people
version control knowledge: 0
how it started
shug writes beautiful code.
200 lines of pure genius.
works perfectly.
shug saves on pendrive 💾
gives to teammate raj...]]></description><link>https://blog.shubhamdalvi.in/shugs-pendrive-disaster-why-git-exists</link><guid isPermaLink="true">https://blog.shubhamdalvi.in/shugs-pendrive-disaster-why-git-exists</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><dc:creator><![CDATA[Shubham Dalvi]]></dc:creator><pubDate>Thu, 01 Jan 2026 15:37:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1767281437552/8d29c8c2-3e2b-44d2-8baa-6c9fa96a09b9.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>the year: <strong>2018</strong></p>
<p>shug is final year student.</p>
<p>project deadline: <strong>2 days</strong></p>
<p>team size: <strong>4 people</strong></p>
<p>version control knowledge: <strong>0</strong></p>
<h2 id="heading-how-it-started">how it started</h2>
<p>shug writes beautiful code.</p>
<p>200 lines of pure genius.</p>
<p>works perfectly.</p>
<p>shug saves on pendrive 💾</p>
<p>gives to teammate raj.</p>
<blockquote>
<p>"add your part bro"</p>
</blockquote>
<h2 id="heading-6-hours-later">6 hours later</h2>
<p>raj returns pendrive.</p>
<p>shug plugs in.</p>
<p>opens project.</p>
<p><strong>everything is broken.</strong></p>
<p>shug's 200 lines: gone.</p>
<p>raj's code: partially there.</p>
<p>nobody knows what happened.</p>
<h2 id="heading-the-investigation">the investigation 🔍</h2>
<p><strong>shug:</strong> "bro what did you do?"</p>
<p><strong>raj:</strong> "i just edited some files"</p>
<p><strong>shug:</strong> "which files?"</p>
<p><strong>raj:</strong> "i don't remember"</p>
<p><strong>shug:</strong> "where is my code?"</p>
<p><strong>raj:</strong> "i thought you had backup"</p>
<p><strong>shug:</strong> 💀</p>
<h2 id="heading-attempts-to-recover">attempts to recover</h2>
<p>shug tries everything:</p>
<ul>
<li><p>check pendrive history (doesn't exist)</p>
</li>
<li><p>ask raj to remember changes (he doesn't)</p>
</li>
<li><p>restore old version (there is none)</p>
</li>
<li><p>cry (very effective)</p>
</li>
</ul>
<p>deadline: tomorrow morning.</p>
<p>shug rewrites 200 lines from memory.</p>
<p>takes 8 hours.</p>
<p>graduates with trauma.</p>
<h2 id="heading-the-pattern-shug-notices">the pattern shug notices</h2>
<p>this wasn't first time.</p>
<p>there were other incidents.</p>
<h3 id="heading-incident-1-email-attachments">incident 1: email attachments</h3>
<ul>
<li><p>shug emails code to priya</p>
</li>
<li><p>priya edits, emails back</p>
</li>
<li><p>shug makes more changes</p>
</li>
<li><p>both versions exist</p>
</li>
<li><p>which one is correct? nobody knows</p>
</li>
</ul>
<h3 id="heading-incident-2-whatsapp-code-sharing">incident 2: whatsapp code sharing</h3>
<ul>
<li><p>copy paste code in chat</p>
</li>
<li><p>loses formatting</p>
</li>
<li><p>loses context</p>
</li>
<li><p>loses sanity</p>
</li>
</ul>
<h3 id="heading-incident-3-folders">incident 3: folders</h3>
<ul>
<li><p><code>project_final</code></p>
</li>
<li><p><code>project_final_v2</code></p>
</li>
<li><p><code>project_final_v2_actually_final</code></p>
</li>
<li><p><code>project_final_v2_actually_final_USE_THIS_ONE</code></p>
</li>
</ul>
<p>chaos.</p>
<h2 id="heading-the-core-problem">the core problem</h2>
<p>humans have terrible memory.</p>
<p>files overwrite each other.</p>
<p>history disappears.</p>
<p>questions nobody can answer:</p>
<ul>
<li><p>what changed?</p>
</li>
<li><p>who changed it?</p>
</li>
<li><p>when did it change?</p>
</li>
<li><p>why did it change?</p>
</li>
<li><p>how to go back?</p>
</li>
</ul>
<h2 id="heading-what-shug-needed">what shug needed</h2>
<p>shug didn't know it yet, but needed:</p>
<ul>
<li><p>automatic memory</p>
</li>
<li><p>complete history</p>
</li>
<li><p>ability to rollback</p>
</li>
<li><p>blame tracking (for raj 😤)</p>
</li>
<li><p>parallel work without collision</p>
</li>
</ul>
<p>basically:</p>
<p><strong>a time machine for code</strong></p>
<h2 id="heading-senior-developer-uncle-appears">senior developer uncle appears</h2>
<p>college tech fest.</p>
<p>shug meets senior developer uncle.</p>
<p>tells whole pendrive story.</p>
<p>uncle laughs.</p>
<blockquote>
<p>"beta, use git"</p>
</blockquote>
<p><strong>shug:</strong> "what is git?"</p>
<p><strong>uncle:</strong> "version control system. remembers everything."</p>
<p><strong>shug:</strong> "everything?"</p>
<p><strong>uncle:</strong> "everything. even what raj deleted."</p>
<p>shug's eyes light up ✨</p>
<h2 id="heading-what-is-version-control">what is version control?</h2>
<p>version control = system that remembers every version of your code.</p>
<p>not manually.<br />not in your brain.<br />automatically.</p>
<p>like save points in video game.</p>
<p>mess up? go back to last save point.</p>
<p>want to see what changed? compare save points.</p>
<h2 id="heading-the-promise">the promise</h2>
<p>with version control:</p>
<ul>
<li><p>no more lost code</p>
</li>
<li><p>no more "who changed this?"</p>
</li>
<li><p>no more "when did this break?"</p>
</li>
<li><p>no more crying before deadline</p>
</li>
</ul>
<p>collaboration becomes possible.</p>
<p>history becomes permanent.</p>
<p>mistakes become reversible.</p>
<h2 id="heading-shug-makes-decision">shug makes decision</h2>
<blockquote>
<p>"uncle, teach me git"</p>
</blockquote>
<p><strong>uncle:</strong> "youtube pe dekh lo"</p>
<p><strong>shug:</strong> 😐</p>
<h2 id="heading-what-shug-learns-preview">what shug learns (preview)</h2>
<p>over next few weeks, shug discovers:</p>
<ul>
<li><p>git tracks changes automatically</p>
</li>
<li><p>git stores complete history</p>
</li>
<li><p>git lets multiple people work safely</p>
</li>
<li><p>git lives on your computer</p>
</li>
<li><p>github stores it online</p>
</li>
</ul>
<p>but first…</p>
<p>shug needs to understand<br /><strong>what git actually does.</strong></p>
<p>🎬 <em>continue to episode 2</em></p>
]]></content:encoded></item><item><title><![CDATA[What GPT? Shug Explain]]></title><description><![CDATA[Shug simple developer.
Shug like small function, no break. Shug brain work like if-else, not like machine learning black magic.
GPT Mean Generative Pretrained Transformer.
Fancy Word.
Shug Hear. Shug Head Pain.
What This Fancy Name Mean?
Generative M...]]></description><link>https://blog.shubhamdalvi.in/what-gpt-shug-explain</link><guid isPermaLink="true">https://blog.shubhamdalvi.in/what-gpt-shug-explain</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[ChaiCohort]]></category><dc:creator><![CDATA[Shubham Dalvi]]></dc:creator><pubDate>Fri, 15 Aug 2025 15:59:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1755273408464/061a51f4-8a56-4059-9324-fb2b6a269192.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Shug simple developer.</p>
<p>Shug like small function, no break. Shug brain work like <code>if-else</code>, not like machine learning black magic.</p>
<p>GPT Mean <strong>Generative Pretrained Transformer</strong>.</p>
<p>Fancy Word.</p>
<p>Shug Hear. Shug Head Pain.</p>
<h3 id="heading-what-this-fancy-name-mean"><strong>What This Fancy Name Mean?</strong></h3>
<p><strong>Generative</strong> Mean GPT Make Thing. You Say "Write Blog". GPT Write Better Blog Than Shug. Shug Cry In Corner. Then Post Anyway.</p>
<p><strong>Pretrained</strong> Mean GPT Read Internet. Whole Internet. Even Those Facebook Auntie Recipes. Shug Still Google "How Center Div". Shame.</p>
<p><strong>Transformer</strong> Not robot movie. No fight scene. Is math black magic. Paper say "<strong>Attention is all you need</strong>". Shug laugh. Think love advice. Is not. Shug look at transformer math, full of big tensors. Brain say "why numbers in 12D?" Shug close laptop, go drink garam chai.</p>
<p><img src="https://dqy38fnwh4fqs.cloudfront.net/UHJKR6OAAQ8LP9EHAG8PRREKPRQQ/blog/blog-content-image-d16067f7-2a3d-4176-853c-cc48cb51e484.webp" alt /></p>
<p>OpenAI name it <strong>ChatGPT</strong>. Simple. Genius. Like naming dosa "Dosa". World clap. Competitors cry in JavaScript.</p>
<p>So GPT = Internet Hoarder + No Sleep + Too Smart. Basically That Friend Who Know Everything And Never Let You Copy Code. But GPT Let You Copy. Good Bot.</p>
<p>Shug no jealous. Maybe little jealous.</p>
<p>In the end, big brain GPT predict next token. Shug happy. Shug safe.</p>
<p>Shug brain tired. Time for garam chai. Bye.</p>
]]></content:encoded></item><item><title><![CDATA[How to Use Binary Search To Find Things Faster🚀]]></title><description><![CDATA[Before we can even begin to understand Binary Search, let's first understand what searching is in general. We used to have a small alphabet book as kids that contained images and corresponding alphabets.

Our mom would ask us to find a random letter ...]]></description><link>https://blog.shubhamdalvi.in/how-to-use-binary-search-to-find-things-faster</link><guid isPermaLink="true">https://blog.shubhamdalvi.in/how-to-use-binary-search-to-find-things-faster</guid><category><![CDATA[Binary Search Algorithm]]></category><category><![CDATA[binary search]]></category><category><![CDATA[Searching Algorithms]]></category><category><![CDATA[linearsearch]]></category><category><![CDATA[BlogsWithCC]]></category><dc:creator><![CDATA[Shubham Dalvi]]></dc:creator><pubDate>Wed, 28 Sep 2022 11:32:05 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/eQ2Z9ay9Wws/upload/v1664363758825/r30CX39hU.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Before we can even begin to understand <strong>Binary Search</strong>, let's first understand what <strong>searching</strong> is in general. We used to have a small alphabet book as kids that contained images and corresponding alphabets.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664339752763/fF6abHnkT.png" alt="image.png" /></p>
<p>Our mom would ask us to find a random letter and we would open the book and search for the letter by referencing the image <em>(For example M for Mango then you would search for a mango image in the book)</em>.</p>
<p>But as you grew up, you became an expert at finding the alphabet in the book. If your mom asked you to find M, then you would be smart enough to know that M will be on some centre page. You would start searching it directly from some random middle page 😎</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664340337032/te-QnhT6J.png" alt="image.png" /></p>
<p>Now let's just analyse the example that I gave. </p>
<p><strong>If you think about it, there are two approaches you can take to find the alphabet.</strong></p>
<ol>
<li><em>Searching every page from the beginning until you find the alphabet.</em></li>
<li><em>Opening a random page and searching the alphabet.</em></li>
</ol>
<p>The second method seems an intelligent move to find the alphabet the fastest way right😉</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664342286473/I9-qHwxd2.gif" alt="ThinkSmartGIF.gif" class="image--center mx-auto" /></p>
<p>So now let me share something with you🤫</p>
<blockquote>
<p>The first approach which we discussed is called <strong>Linear Search</strong>. You are linearly searching the alphabet without skipping a single page until you find the desired alphabet.</p>
</blockquote>
<p>For finding the alphabet using <strong>Linear search</strong> we will start searching from page 1 until we get the alphabet we are looking for. Let's say you are searching for the letter <strong>D</strong>. Using Linear Search you will start from the letter <strong>A</strong> and keep flipping the page unless it's <strong>D</strong>.</p>
<p>This seems to be taking a long time, right? And did you think of searching for the letter <strong>Z</strong>? We would have to make 25 searches and after that, we would find <strong>Z</strong>😵‍💫</p>
<p>Imagine finding a word in the <strong>dictionary</strong> by using the Linear Search method😶‍🌫️</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664341839318/ORQ24eZN6.png" alt="image.png" /></p>
<p>What is the fast alternative?🤔</p>
<p>Remember the second method, the smart move we made while searching the alphabet?
Based on the alphabet we had to search we were opening pages randomly and searching them!</p>
<p>Let's discuss a little about this method.</p>
<p>So let's take an example of finding the letter <strong>M</strong> in the book. Suppose the page number is from 1 to 26 where on page 1 there is the letter <strong>A</strong> and so on. Now smartly you will think that the letter <strong>M</strong> lies somewhere in between i.e. on page 13. Tada, on page 13 there will be the letter <strong>M</strong> (<em>Since M is the 13th alphabet</em>). So for the linear search, you would take <strong><em>13 steps</em></strong> to find M, but by using the smart way you found <strong>M</strong> in the first step!</p>
<p>Isn't that amazing?🤩
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664340774286/uvcthkvh-.png" alt="image.png" /></p>
<p>But remember this method will work only if the alphabets are in order. Otherwise, this method is useless and we will have to use the <strong>Linear search</strong>.</p>
<p>The smart way we have learned so far can help us locate any alphabet in a few steps. The only condition required is that the alphabet should be sorted. <strong>Binary Search</strong> is the smart way of doing this.</p>
<p>Let us now understand how binary search can help us find our desired output in a few steps.
Let's take an example of finding the letter <strong>F</strong>.</p>
<p>Steps:</p>
<ol>
<li><strong>Find the middle element</strong>
First, we will find the middle alphabet. Here the middle alphabet is the letter <strong>M</strong>.</li>
<li><strong>Check if the target is greater or smaller than the middle element</strong>
The letter <strong>F</strong> lies before the letter <strong>M</strong>. So we can say that the letter <strong>F</strong> is smaller than the middle alphabet.</li>
<li><strong>If the target is smaller than the middle element then search on the left side</strong>
So we will now check for the target from the start to the middle alphabet i.e. We will search for the letter <strong>F</strong> in between <strong>A</strong> and <strong>M</strong>.</li>
</ol>
<p>So if you look closely we are reducing the range of searching and we are finding the target. The half of 13 is 6 (considering the integer value) and on page 6 there will be the letter F (<em>Since F is the 6th alphabet</em>). This is how we found the letter F in 2 steps using Binary Search.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664356647517/k5WZ5wwzq.jpg" alt="Untitled.jpg" /></p>
<blockquote>
<p>To summarise,
We need to follow the following steps  for Binary search:</p>
<ol>
<li>Find the middle element.</li>
<li>Check if the target is greater or smaller than the middle element.</li>
<li>If the target is greater than the middle element, search on the right-hand side.</li>
<li>Else, if the target is smaller than the middle element, search on the left-hand side.</li>
<li>Repeat steps 2, 3 and 4 till the middle element is equal to the target.</li>
</ol>
</blockquote>
<p>Let's take another example.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664357299810/ehRFBOfzb.jpg" alt="Untitled (1).jpg" /></p>
<blockquote>
<p>The first thing you should check before applying <strong>Binary Search</strong> is to check whether the given range is <strong>sorted</strong>. Once we verified, you can go ahead and apply binary search.</p>
</blockquote>
<ol>
<li><p><strong>Find the middle element.</strong></p>
<p>The middle element in the above array is 11. <em>(4th element in the array is 11)</em></p>
<pre><code>middle = (start + end) / <span class="hljs-number">2</span> 
middle =&gt; (<span class="hljs-number">0</span> + <span class="hljs-number">9</span>) / <span class="hljs-number">2</span> 
middle =&gt; <span class="hljs-number">4</span>
</code></pre></li>
<li><p><strong>Check if the target is greater or smaller than the middle element.</strong></p>
<p>If the target element is greater than the middle element, check on the right side.</p>
<pre><code><span class="hljs-keyword">if</span> ( target &gt; middle ) =&gt; check on the right
</code></pre><p>Whereas, If the target element is smaller than the middle element, check on the left side.</p>
<pre><code><span class="hljs-keyword">if</span> ( target &lt; middle ) =&gt; check on the left
</code></pre><p>In our case, 36 &gt; 11, thus we have to check on the right side.</p>
</li>
</ol>
<p>Repeating steps 1 and 2 again.</p>
<pre><code>middle = (start + end) / <span class="hljs-number">2</span> 
middle =&gt; (<span class="hljs-number">5</span> + <span class="hljs-number">9</span>) /<span class="hljs-number">2</span> 
middle =&gt; <span class="hljs-number">14</span> / <span class="hljs-number">2</span> 
middle =&gt; <span class="hljs-number">7</span>
</code></pre><p>The 7th element in the array is 20. In this case 36 &gt; 20, thus we again have to check on the right side.</p>
<p>Repeating steps 1 and 2 again.</p>
<pre><code>middle = (start + end) / <span class="hljs-number">2</span> 
middle =&gt; (<span class="hljs-number">7</span> + <span class="hljs-number">9</span>) /<span class="hljs-number">2</span> 
middle =&gt; <span class="hljs-number">16</span> / <span class="hljs-number">2</span> 
middle =&gt; <span class="hljs-number">8</span>
</code></pre><p>The 8th element in the array is 36. Hurray! we have finally found out 36.</p>
<p>If you see we have found 36 in just 4 steps. If we used linear search, we would require 8 steps to find 36.</p>
<p>Let's now understand the Time complexity of Binary search.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664360134972/gbeU6n4Z5.jpg" alt="Untitled (4).jpg" /></p>
<blockquote>
<p>Here the space in which we are searching is getting divided into two parts.</p>
</blockquote>
<p>In the first step, when the array is not split, the size of the array is,</p>
<pre><code>N / <span class="hljs-number">2</span>^<span class="hljs-number">0</span>
</code></pre><p>In the second step, it becomes</p>
<pre><code>N / <span class="hljs-number">2</span>^<span class="hljs-number">1</span>
</code></pre><p>In the third step, it becomes</p>
<pre><code>N / <span class="hljs-number">2</span>^<span class="hljs-number">2</span>
</code></pre><p>Thus at the k^th step,</p>
<pre><code>N / <span class="hljs-number">2</span>^k = <span class="hljs-number">1</span>
</code></pre><p>It is equal to 1 because the size of the array is reduced to 1 element only i.e. the target element.</p>
<p>Thus if we solve this further,</p>
<pre><code>N = <span class="hljs-number">2</span>^k    <span class="hljs-comment">// Shifting 2^k on the Right side</span>
log ( N ) = log ( <span class="hljs-number">2</span>^k )    <span class="hljs-comment">// Taking log on both sides</span>
log ( N ) = k * log( <span class="hljs-number">2</span> )
log ( N ) / log ( <span class="hljs-number">2</span> ) = k
k = log2 ( N )
</code></pre><p>Here k is the total number of comparisons done while finding the target element and N is the size of the array. Thus the time complexity of Binary search is O(log (N)).</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664361210276/0PF4ivp-G.png" alt="image.png" class="image--center mx-auto" /></p>
<p>Now that you have a fundamental understanding of Binary Search, you can easily understand its implementation in any programming language you like!</p>
<p>Did you find this useful?🤔 
Feel free to like and save it to your timeline for reference later!😊</p>
<p>Thanks for reading ✨</p>
]]></content:encoded></item></channel></rss>