<?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>Forem: Satpalsinh Rana</title>
    <description>The latest articles on Forem by Satpalsinh Rana (@satpalsinhrana).</description>
    <link>https://forem.com/satpalsinhrana</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%2F2216361%2Fd2faaf25-42ba-4e94-aa3b-efd75532d2c0.png</url>
      <title>Forem: Satpalsinh Rana</title>
      <link>https://forem.com/satpalsinhrana</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/satpalsinhrana"/>
    <language>en</language>
    <item>
      <title>Domain Name System (DNS): What It Is and How It Functions</title>
      <dc:creator>Satpalsinh Rana</dc:creator>
      <pubDate>Sat, 24 Jan 2026 10:33:14 +0000</pubDate>
      <link>https://forem.com/satpalsinhrana/domain-name-system-dns-what-it-is-and-how-it-functions-2d86</link>
      <guid>https://forem.com/satpalsinhrana/domain-name-system-dns-what-it-is-and-how-it-functions-2d86</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;The Internet Addressing System&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In the world of the internet, every device (node) connected to the network needs a unique identifier to communicate. This identifier is known as an &lt;strong&gt;IP Address&lt;/strong&gt;. You can think of it like the GPS Coordinates of your House.&lt;/p&gt;

&lt;p&gt;1. IPv4 (Internet Protocol version 4)&lt;/p&gt;

&lt;p&gt;This is the legacy format we are most familiar with. It looks like 192.168.0.1.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Format:&lt;/strong&gt; It consists of four octets separated by dots. Each octet is a decimal value between 0 and 255.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Capacity:&lt;/strong&gt; IPv4 uses 32 bits. Total Addresses = 2³² = 4,294,967,296 (~4.3 billion)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As the internet has evolved, our devices have become smarter. We now have internet connected Air Conditioners, Washing Machines, Cars, and countless IoT devices. With billions of humans and tens of billions of devices, the 4.3 billion IPv4 addresses have essentially been exhausted.&lt;/p&gt;

&lt;p&gt;2. IPv6 (Internet Protocol version 6)&lt;/p&gt;

&lt;p&gt;To solve the exhaustion problem, IPv6 was introduced. It looks like 2001:0db8:85a3:0000:0000:8a2e:0370:7334.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Format:&lt;/strong&gt; It uses hexadecimal format.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Capacity:&lt;/strong&gt; IPv6 uses 128 bits. Total\ Addresses = 2¹²⁸ = 340,282,366,920,938,463,463,374,607,431,768,211,456.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is 340 undecillion addresses. We will not run out of IP anytime soon.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;The Human Brain&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Let’s understand how the human brain works. Our brains are wired to love strings, words, names, and stories. Not long, random numbers.&lt;/p&gt;

&lt;p&gt;Imagine a friend comes to you and says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"I have two houses. The first is located at GPS Coordinates 28.6139° N, 77.2090° E, and the second is at 19.0760° N, 72.8777° E."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You simply won’t remember that. However, it is instantly clear and memorable if they say:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"11, Elite Bunglows, New Delhi, India"&lt;/em&gt; or &lt;em&gt;"15, Chai Bunglows, Mumbai, India."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The internet works the same way. When you want to visit a website, you shouldn’t have to memorize a server’s IP address. You need a memorable name. This is where &lt;strong&gt;Domains&lt;/strong&gt; come in.&lt;/p&gt;

&lt;h3&gt;
  
  
  Domain
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;domain&lt;/strong&gt; is a unique, human-readable name that identifies a resource on the Internet and maps to one or more &lt;strong&gt;IP addresses&lt;/strong&gt; using the Domain Name System.&lt;/p&gt;

&lt;p&gt;Have you heard of ICANN?&lt;/p&gt;

&lt;p&gt;ICANN (Internet Corporation for Assigned Names and Numbers) is the global organization responsible for coordinating the allocation of &lt;strong&gt;domain names and IP address spaces&lt;/strong&gt; to ensure uniqueness across the Internet.&lt;/p&gt;

&lt;p&gt;You can think of ICANN as the &lt;strong&gt;global registry and policy authority&lt;/strong&gt; that oversees:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Domain name uniqueness&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Top-level domains like &lt;code&gt;.com&lt;/code&gt;, &lt;code&gt;.org&lt;/code&gt;, &lt;code&gt;.in&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;IP address distribution through regional registries&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because of ICANN’s coordination, when you type &lt;em&gt;google.com&lt;/em&gt;, it resolves to Google’s servers and not to any other organization. No two entities can own the same domain name in the global DNS system.&lt;/p&gt;

&lt;p&gt;So now, you understand what a domain is.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Question Time: When you type &lt;em&gt;google.com&lt;/em&gt; into your browser, how exactly is that IP address found?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You might be wondering:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Does my Chrome browser memorize every IP on the internet? (Sorry Brave fans.)&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Does my laptop know where Google is hosted?&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Or is there some mysterious third-party service doing the work?&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The answer is a big No.&lt;/p&gt;

&lt;p&gt;No single device knows everything. The internet is too big (remember, millions of websites). Instead, it works like a Detective Investigation. And the system that does the investigation is known as the Domain Name System.&lt;/p&gt;

&lt;h2&gt;
  
  
  DNS
&lt;/h2&gt;

&lt;p&gt;DNS translates Domain names to IP addresses.&lt;/p&gt;

&lt;p&gt;DNS services include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Host to IP address.&lt;br&gt;&lt;br&gt;
E.g. google.com to 142.251.220.14&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Host aliasing&lt;br&gt;&lt;br&gt;
Allows multiple domain names to map to the same canonical domain using CNAME records.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Email routing&lt;br&gt;&lt;br&gt;
Allow a domain to specify which mail servers are responsible for receiving the email.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;IP address to Host&lt;br&gt;&lt;br&gt;
E.g. 142.251.220.14 to google.com&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Load Balancing&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;DNS Resolution: The Hierarchy of "Whom to Meet Next?"&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;When you type &lt;em&gt;google.com&lt;/em&gt;, your browser doesn't get the IP address in one magical shot. It is a hierarchical, recursive process.&lt;/p&gt;

&lt;p&gt;Think of it like looking for a person living in a massive office building. You don't know where they live, so you ask for directions. Each person you ask doesn't give you the final answer, they just answer the question: &lt;strong&gt;"Whom should I meet next?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's trace the journey of &lt;em&gt;google.com&lt;/em&gt;:&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Step 1: Browser Cache&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Before doing anything, your browser (Chrome, Firefox, Safari) checks its own temporary memory.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Question:&lt;/strong&gt; &lt;em&gt;"Have I visited google.com&lt;/em&gt; in the last few minutes?"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;If Yes:&lt;/strong&gt; It uses the saved IP immediately. No network request is made.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;If No:&lt;/strong&gt; It proceeds to Step 2.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Step 2: OS Cache&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;The browser asks your Operating System (Windows, macOS, Linux). The OS maintains its own cache and also checks a special text file called the &lt;strong&gt;"hosts file"&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Question:&lt;/strong&gt; &lt;em&gt;"Hey Windows, do you have a record for google.com&lt;/em&gt;?"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;If Yes:&lt;/strong&gt; The OS gives the IP to the browser.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;If No:&lt;/strong&gt; The OS realizes it doesn't know the answer locally. It needs outside help.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Step 3: The DNS Resolver (The Assistant)&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Browser is the Boss. The Boss is busy rendering pages and chats of ChatGPT, it doesn't have time to run around the internet asking for directions. So, when the cache comes up empty, the Browser delegates the task to its assistant.&lt;/p&gt;

&lt;p&gt;This is the moment your request actually leaves your computer. The query travels to the Resolver, which is usually provided by your &lt;strong&gt;ISP&lt;/strong&gt; (Internet Service Provider) or a public DNS service like &lt;strong&gt;Google (8.8.8.8)&lt;/strong&gt; or &lt;strong&gt;Cloudflare (1.1.1.1)&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Question:&lt;/strong&gt; &lt;em&gt;"I need the IP for google.com.&lt;/em&gt; Go find it for me."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Resolver's Job:&lt;/strong&gt; It is now the Resolver's responsibility to hunt down the answer. It starts the &lt;strong&gt;"Whom to meet next?"&lt;/strong&gt; journey across the internet.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It’s check inside it’s cache. Because the resolver caches this result for a time period called &lt;strong&gt;TTL (Time To Live)&lt;/strong&gt; so that future requests can be answered faster without repeating the entire process.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;If No:&lt;/strong&gt; It goes to Root DNS Server.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Step 4: The Root DNS Server (.)&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;The Resolver asks the Root Server.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Answer:&lt;/strong&gt; &lt;em&gt;"I don't know the IP, but google.com&lt;/em&gt; ends in “.com”. Go ask the “.com” TLD Server."&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Step 5: The TLD DNS Server (.com)&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;The Resolver asks the “.com” TLD Server.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Answer:&lt;/strong&gt; &lt;em&gt;"I don't know the IP, but I know google.com&lt;/em&gt; is managed by Google's Name Servers. Go ask the &lt;strong&gt;Authoritative Server&lt;/strong&gt;."&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Step 6: The Authoritative Name Server&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;The Resolver asks Google's Authoritative Server.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Answer:&lt;/strong&gt; &lt;em&gt;"Yes, I am the authority. The IP address is&lt;/em&gt; &lt;code&gt;142.251.220.14&lt;/code&gt;."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Finish Line:&lt;/strong&gt; The Resolver brings this IP back to your Browser and finally, the website loads.&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%2Fx5hknnewvhbi1qx2i90b.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%2Fx5hknnewvhbi1qx2i90b.png" alt="DNS" width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Tea Break ☕ :)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Question Time: How does it know when to stop?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It checks the Answer Type:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;"Go Ask Someone Else" (NS Record): The Resolver knows to keep going to the next server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;"Here is the IP" (A Record or AAAA record for IPv6): The Resolver knows the search is finished.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We’ve seen how the detective works in theory. Now, let’s hand you the badge and let you do the investigation yourself. Meet our friend &lt;strong&gt;DIG&lt;/strong&gt;, a command-line utility.&lt;/p&gt;

&lt;h2&gt;
  
  
  DIG
&lt;/h2&gt;

&lt;p&gt;DIG stands for Domain Information Groper. As the name suggests, we can use this utility to perform DNS queries.&lt;/p&gt;

&lt;p&gt;Let’s try using dig for &lt;em&gt;google.com&lt;/em&gt; in the terminal, or try it online:(&lt;a href="https://toolbox.googleapps.com/apps/dig/" rel="noopener noreferrer"&gt;https://toolbox.googleapps.com/apps/dig&lt;/a&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2F0bnyb1ugofpnf4g2mpjl.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%2F0bnyb1ugofpnf4g2mpjl.png" alt="dig google.com" width="800" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will get a lot of output, but don't panic. You only need to look at the &lt;strong&gt;"ANSWER SECTION"&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Domain         TTL       Internet       Type        IP Address
&lt;span class="nt"&gt;----------------------------------------------------------------&lt;/span&gt;
google.com.    120         IN            A        172.217.25.78
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you understand how to query DNS using DIG. But what is TTL?&lt;/p&gt;

&lt;h3&gt;
  
  
  TTL
&lt;/h3&gt;

&lt;p&gt;TTL stands for &lt;strong&gt;Time To Live&lt;/strong&gt;. It is the amount of time a DNS record can be cached before it must be re-queried. This is why, when we update a DNS record, it takes time for the change to be seen everywhere.&lt;/p&gt;

&lt;p&gt;Imagine a resolver asks for Google’s IP and gets the answer. The resolver stores it in its cache and sets a timer (TTL) for &lt;strong&gt;1 hour&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now, imagine 5 minutes later, Google’s admin changes the IP address on the authoritative DNS server.&lt;/p&gt;

&lt;p&gt;But, The resolver doesn't know. If your browser asks the resolver again, the resolver will not go back to the server. The resolver will just look at their cache, see the valid timer, and give you the old (now wrong) IP address.&lt;/p&gt;

&lt;p&gt;This is why we say the update "takes time to propagate." Propagation is not the time it takes for data to travel across the internet, it is the time we spend waiting for everyone's timers to run out.&lt;/p&gt;

&lt;h3&gt;
  
  
  DIG commands
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Quick Check: You just want the IP address.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig google.com +short
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fbz65sw5lgu2j7eipz0ai.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%2Fbz65sw5lgu2j7eipz0ai.png" alt="dig google.com +short" width="353" height="47"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Full Investigation:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig google.com +trace
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fx9x7mocfdg7r9ypz9q5y.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%2Fx9x7mocfdg7r9ypz9q5y.png" alt="dig google.com +trace" width="800" height="463"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Return the log containing:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Block 1 (The Root): You asked the Root Server. It said: "I don't know, go ask the .com servers."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Block 2 (The TLD): You asked the .com Server. It said: "I don't know, go ask Google's Name servers."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Block 3 (The Authority): You asked Google's Name Server. It said: "Here is the IP: 172.217.26.206."&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Get Authoritative Name Server:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig google.com NS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Ftb8wvdl3cgp19hfbnngf.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%2Ftb8wvdl3cgp19hfbnngf.png" alt="dig google.com NS" width="663" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check with Google or Cloudflare Resolver:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig @8.8.8.8 google.com &lt;span class="c"&gt;#Google DNS resovler&lt;/span&gt;
&lt;span class="c"&gt;#OR&lt;/span&gt;
dig @1.1.1.1 google.com &lt;span class="c"&gt;#CloudFlare DNS resolver&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Reverse Lookup&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig &lt;span class="nt"&gt;-x&lt;/span&gt; 142.251.220.14
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This uses PTR records under the &lt;code&gt;in-addr.arpa&lt;/code&gt; domain.&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%2F2to8m32fplficnz3cj2b.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%2F2to8m32fplficnz3cj2b.png" alt="DIG&amp;amp;Browser" width="800" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;The Domain Name System (DNS) is a critical component of the internet that translates human-readable domain names into machine-readable IP addresses. It allows users to access websites without needing to remember complex numerical addresses, ensuring efficient and seamless communication across the digital landscape. Understanding DNS processes and tools can help optimize internet interactions.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The best technology is the kind that works so well you don't even notice it."&lt;/p&gt;

&lt;p&gt;— Anonymous&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>dns</category>
      <category>webdev</category>
      <category>ttl</category>
    </item>
    <item>
      <title>What's Inside the .git Folder?</title>
      <dc:creator>Satpalsinh Rana</dc:creator>
      <pubDate>Fri, 09 Jan 2026 20:36:04 +0000</pubDate>
      <link>https://forem.com/satpalsinhrana/whats-inside-the-git-folder-2obg</link>
      <guid>https://forem.com/satpalsinhrana/whats-inside-the-git-folder-2obg</guid>
      <description>&lt;p&gt;In this article, we are going to open the hood and look at the engine. We are going to explore the &lt;strong&gt;.git&lt;/strong&gt; folder.&lt;/p&gt;

&lt;p&gt;By the end of this article, you’ll understand how Git stores files, tracks history internally, and how commits are built under the hood.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;Before we dive into the hexadecimal rabbit hole, let’s make sure we are on the same page. You don’t need to be a Git wizard to follow along, but you should be comfortable with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Basic Git Commands:&lt;/strong&gt; You have used &lt;code&gt;git add&lt;/code&gt;, &lt;code&gt;git commit&lt;/code&gt;, and &lt;code&gt;git push&lt;/code&gt; before.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Command Line:&lt;/strong&gt; You know how to open a terminal and navigate folders (&lt;code&gt;cd&lt;/code&gt;, &lt;code&gt;ls&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Curiosity:&lt;/strong&gt; You are willing to look at things that might seem abstract at first!&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;New to Git?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
If you want to refresh the basics first, check out:&lt;br&gt;&lt;br&gt;
&lt;a href="https://dev.to/satpalsinhrana/learn-git-easily-a-beginners-guide-to-version-control-47e2"&gt;Learn Git Easily: A Beginner's Guide to Version Control&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  What is the &lt;code&gt;.git&lt;/code&gt; Folder ?
&lt;/h2&gt;

&lt;p&gt;If you open any Git repository on your computer and enable "show hidden files," you will see a folder named &lt;code&gt;.git&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;This isn't just a config folder, it is a database. It is the brain, heart, and soul of your repository. If you delete your project files but keep the &lt;code&gt;.git&lt;/code&gt; folder, you can restore everything. If you delete the &lt;code&gt;.git&lt;/code&gt; folder, your project becomes just a regular folder of text files, and all your history is lost.&lt;/p&gt;

&lt;p&gt;Git is essentially a &lt;strong&gt;content-addressable filesystem&lt;/strong&gt;. That’s a fancy way of saying it’s a key-value store.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Blob: When you create a file like &lt;code&gt;main.ts&lt;/code&gt; , Git looks at the contents of that file. It compresses the content and stores it as a Blob.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tree: A blob has content, but it doesn't have a name. That's where the Tree comes in. It maps names (like &lt;code&gt;main.ts&lt;/code&gt;) to Blob IDs. It can also contain other Trees (subdirectories). This is how Git reconstructs your folder structure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Commit: The Commit object is the wrapper that ties it all together. A pointer to a specific Tree, metadata, and a pointer to the parent commit.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Simple terms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Blob:&lt;/strong&gt; The data (File content).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tree:&lt;/strong&gt; The structure (Folder organization).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Commit:&lt;/strong&gt; The snapshot (Who, when, and why).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  SHA-1 Hashes
&lt;/h2&gt;

&lt;p&gt;You’ve likely seen those long strings of random characters like &lt;code&gt;a1b2c3d...&lt;/code&gt; . This are SHA-1 Hashes.&lt;/p&gt;

&lt;p&gt;Every time you create an object, Git runs a mathematical formula on the content to generate this 40-character ID.&lt;/p&gt;

&lt;p&gt;Here, SHA stands for Secure Hash Algorithm.&lt;/p&gt;

&lt;p&gt;Newer versions of Git now support &lt;strong&gt;SHA-256&lt;/strong&gt; as an option, but it is not the default yet because the entire ecosystem (GitHub, GitLab, tools) is still built around SHA-1 compatibility.&lt;/p&gt;

&lt;p&gt;To check which hashing algorithm your specific Git repository is using, you can run this command in your terminal inside the repo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git rev-parse &lt;span class="nt"&gt;--show-object-format&lt;/span&gt;
&lt;span class="c"&gt;# rev-parse - Git plumbing command that resolves and parses Git references (hashes, branches, tags)&lt;/span&gt;
&lt;span class="c"&gt;# --show-object-format - Displays the object hash format used by this repository (sha1 or sha256)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fkvpdqvqj2s184132jd55.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%2Fkvpdqvqj2s184132jd55.png" alt="Command Result" width="456" height="52"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What happens when you commit?
&lt;/h2&gt;

&lt;p&gt;Let’s trace the journey of a file from your editor to the repository.&lt;/p&gt;

&lt;p&gt;Step 1: &lt;code&gt;git add .&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When you run &lt;code&gt;git add&lt;/code&gt;, you aren't just "marking" files. You are actively writing to the database.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Git takes the content of your modified files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It creates &lt;strong&gt;Blob objects&lt;/strong&gt; for them immediately and stores them in &lt;code&gt;.git/objects&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It updates the &lt;strong&gt;Index&lt;/strong&gt; (or Staging Area). The Index is just a list that says, "For the next commit, this filename points to this specific Blob hash."&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Step 2: &lt;code&gt;git commit -m "Message"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When you run &lt;code&gt;git commit&lt;/code&gt;, Git creates a permanent snapshot.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tree Creation:&lt;/strong&gt; Git looks at your Index (Staging Area) and creates &lt;strong&gt;Tree objects&lt;/strong&gt; that represent your current folder structure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Commit Creation:&lt;/strong&gt; Git creates a &lt;strong&gt;Commit object&lt;/strong&gt;. This object points to the main Tree you just created and links back to the previous commit (the parent).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Head Update:&lt;/strong&gt; Finally, Git moves the &lt;code&gt;HEAD&lt;/code&gt; pointer (your current branch label) to point to this new commit ID.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So, this is where the integrity magic happens.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If you have a file with the text &lt;code&gt;"Hello World"&lt;/code&gt;, the hash will always be the same.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you change &lt;code&gt;"Hello World"&lt;/code&gt; to &lt;code&gt;"Hello Worlds"&lt;/code&gt;, the hash changes completely.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Git hashes not only the content, but also the object type and size. This guarantees uniqueness and integrity. Git objects don't just exist in isolation, they point to each other using these hashes. This dependency creates a chain reaction. This happens because every commit also includes the hash of its parent commit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deep Dive: Folder Structure
&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%2Fc2n467f7rlg0lk4vbtqy.jpg" 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%2Fc2n467f7rlg0lk4vbtqy.jpg" alt=".git Folder structure" width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  HEAD (The "You Are Here" Pointer)
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;HEAD&lt;/code&gt; file is a simple text file that tells Git where you are currently working. It contains a reference to the active branch.&lt;/p&gt;

&lt;p&gt;If you open it, you will typically see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ref: refs/heads/main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tells Git: &lt;em&gt;"We are currently on the&lt;/em&gt; &lt;code&gt;main&lt;/code&gt; branch." When you run &lt;code&gt;git checkout dark-mode&lt;/code&gt;, Git simply updates this file to point to &lt;code&gt;refs/heads/dark-mode&lt;/code&gt;. It is essentially a dynamic pointer.&lt;/p&gt;

&lt;h3&gt;
  
  
  objects/ (The Database)
&lt;/h3&gt;

&lt;p&gt;This is the most important folder. It acts as the local database where Git stores all your data—content (blobs), folder structures (trees), and history (commits).&lt;/p&gt;

&lt;p&gt;Every object is stored here, named by its unique SHA-1 hash.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to inspect an object:&lt;/strong&gt; Since these files are compressed binaries, you cannot open them in a text editor. Instead, use the &lt;code&gt;git cat-file&lt;/code&gt; command to read them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git cat-file &lt;span class="nt"&gt;-p&lt;/span&gt; &amp;lt;object-id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-p&lt;/code&gt;: Pretty-print the content (make it human-readable).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example Output of a Commit Object:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tree 8d3a1...
parent 1f4e2...
author Satpal Rana &amp;lt;satpal@example.com&amp;gt; 1703865000 +0000

Created the homepage hero section
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  refs/ (The Bookmarks)
&lt;/h3&gt;

&lt;p&gt;If &lt;code&gt;objects/&lt;/code&gt; is the library of books, &lt;code&gt;refs/&lt;/code&gt; is the catalog of bookmarks. This folder stores your &lt;strong&gt;Branches&lt;/strong&gt; and &lt;strong&gt;Tags&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Heads:&lt;/strong&gt; Found in &lt;code&gt;refs/heads/&lt;/code&gt;. If you have a branch named &lt;code&gt;feature-login&lt;/code&gt;, there is a file named &lt;code&gt;feature-login&lt;/code&gt; in this folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The content:&lt;/strong&gt; The file contains nothing but a &lt;strong&gt;40-character Commit Hash&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is why creating branches in Git is so fast. Git doesn't copy your files, it just creates a tiny text file containing the hash of the current commit.&lt;/p&gt;

&lt;h3&gt;
  
  
  index (The Staging Area)
&lt;/h3&gt;

&lt;p&gt;This is a binary file that acts as the "Staging Area." When you run &lt;code&gt;git add&lt;/code&gt;, Git updates this &lt;code&gt;index&lt;/code&gt; file. It builds a list of file information (timestamps, filenames, and blob hashes) that are ready to be packaged into the next commit.&lt;/p&gt;

&lt;h3&gt;
  
  
  config (Project Settings)
&lt;/h3&gt;

&lt;p&gt;This text file contains configuration specific to this repository, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The URL of the remote repository (&lt;code&gt;origin&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Local user overrides.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Branch tracking information.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Hand’s On Git
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Create a new repository:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git init demo
&lt;span class="nb"&gt;cd &lt;/span&gt;demo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create a file and commit it:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello Git"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; hello.txt
git add &lt;span class="nb"&gt;.&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"First commit"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Explore the objects:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; .git/objects
git cat-file &lt;span class="nt"&gt;-p&lt;/span&gt; &amp;lt;object-id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Observe how Git stores and retrieves data internally.&lt;/p&gt;

&lt;p&gt;In this article, we explored how Git stores data internally using blobs, trees, commits, and hashes. Understanding this makes Git feel less magical and more predictable.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Hidden folders sometimes hold the biggest secrets.”&lt;br&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;— Anonymous Developer&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>git</category>
    </item>
    <item>
      <title>Learn Git Easily: A Beginner's Guide to Version Control</title>
      <dc:creator>Satpalsinh Rana</dc:creator>
      <pubDate>Thu, 01 Jan 2026 17:43:02 +0000</pubDate>
      <link>https://forem.com/satpalsinhrana/learn-git-easily-a-beginners-guide-to-version-control-47e2</link>
      <guid>https://forem.com/satpalsinhrana/learn-git-easily-a-beginners-guide-to-version-control-47e2</guid>
      <description>&lt;p&gt;If you have ever struggled with sharing your code via pen drives or sending endless zip files through email, you are in the right place. It’s time to introduce you to Git.&lt;/p&gt;

&lt;h2&gt;
  
  
  Git
&lt;/h2&gt;

&lt;p&gt;In technical terms, Git is a Distributed Version Control System (DVCS).&lt;/p&gt;

&lt;p&gt;In simple terms, Git is a time machine for our projects. It tracks every modification you make to our code. If you break something, you can simply "rewind" to a previous state where everything worked.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do we use it?
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Collaborations:&lt;/strong&gt; Multiple people can work on the same file at the same time without overwriting each other’s work.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Distributed Architecture:&lt;/strong&gt; Every developer gets their own local version of the repository with the full history and commits. It supports offline work and has no single point of failure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Branching and Merging: Developers create a separate branch to work on a feature and can merge it into the main branch.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Terminology Dictionary
&lt;/h2&gt;

&lt;p&gt;Developers love using fancy words for simple things. Here is your translation guide to help you go through the article.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Term&lt;/th&gt;
&lt;th&gt;What it means&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Repository (Repo)&lt;/td&gt;
&lt;td&gt;The folder containing all your project files and the entire revision history.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Commit&lt;/td&gt;
&lt;td&gt;A snapshot of your code at a specific point in time. It has a unique ID (hash).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Staging Area&lt;/td&gt;
&lt;td&gt;The list of files you are planning to commit next.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Local&lt;/td&gt;
&lt;td&gt;The version of the repository stored on your personal computer.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Remote&lt;/td&gt;
&lt;td&gt;The version of the repository stored on the internet (like GitHub/GitLab).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Clone&lt;/td&gt;
&lt;td&gt;Downloading a remote repository to your computer.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Push&lt;/td&gt;
&lt;td&gt;Uploading your local commits to the remote server.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pull&lt;/td&gt;
&lt;td&gt;Downloading changes from the remote server to your local machine.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Merge&lt;/td&gt;
&lt;td&gt;Taking code from one branch and combining it into another.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Branch&lt;/td&gt;
&lt;td&gt;A parallel version of your code. Changes here do not affect the main project until you merge them.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HEAD&lt;/td&gt;
&lt;td&gt;A pointer to the specific commit you are currently looking at or working on.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Origin&lt;/td&gt;
&lt;td&gt;The default nickname Git gives to the remote URL (where you cloned from).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pull Request (PR)&lt;/td&gt;
&lt;td&gt;A request to merge your branch into the main branch. (Used on GitHub/GitLab).&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The Core Architecture
&lt;/h2&gt;

&lt;p&gt;Before moving to the commands, we must understand the three stages.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Working Directory (The Workbench): This is the actual folder where we type our code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Staging Area (The Box): Pick specific files from the workbench and put in the box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Local Repository (The Shipping Truck): You seal the box and label it. This is a Commit. It is part of the code history now.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&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%2Fdqzn47fhrj7nrcp2v6mk.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%2Fdqzn47fhrj7nrcp2v6mk.png" alt="GIT Architecture" width="800" height="358"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How a Repository looks
&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%2F824q4my4to7imbs23ge9.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%2F824q4my4to7imbs23ge9.png" alt="Project Structure" width="800" height="619"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;src/&lt;/code&gt;: The folder containing your actual source code, keeping the project organized.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;.gitignore&lt;/code&gt;: A text file listing everything Git should intentionally ignore (like secrets).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;README.md&lt;/code&gt;: The instruction manual that explains what your project is and how to run it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;LICENSE&lt;/code&gt;: The legal document stating how others are allowed to use or copy your code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;.git/&lt;/code&gt;: The hidden database where Git stores your entire project history and save points.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Developer Workflow
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Initialize
&lt;/h3&gt;

&lt;p&gt;Tell Git to watch your folder&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Check Status
&lt;/h3&gt;

&lt;p&gt;Want to check your repo’s status&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stage
&lt;/h3&gt;

&lt;p&gt;Create a file named &lt;code&gt;index.html&lt;/code&gt;. Now run &lt;code&gt;git status&lt;/code&gt; again. You will see the file in &lt;strong&gt;red&lt;/strong&gt; (Untracked). Let's move it to the staging area using the command below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To add all changed files at once, use &lt;code&gt;git add .&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Run &lt;code&gt;git status&lt;/code&gt; again. The file is now &lt;strong&gt;green&lt;/strong&gt;. It is staged and ready to be saved.&lt;/p&gt;

&lt;h3&gt;
  
  
  Commit
&lt;/h3&gt;

&lt;p&gt;Now we permanently save this snapshot to the history. You &lt;strong&gt;must&lt;/strong&gt; include a message describing what you did.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Created the homepage file"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;-m&lt;/code&gt;: Stands for "message".&lt;/p&gt;

&lt;h3&gt;
  
  
  Lazy Shortcut
&lt;/h3&gt;

&lt;p&gt;Tired of typing &lt;code&gt;git add&lt;/code&gt; and then &lt;code&gt;git commit&lt;/code&gt; every single time? We can combine them into one command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;-am&lt;/span&gt; &lt;span class="s2"&gt;"Updated the style"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will NOT stage new (untracked) files. Only modified/deleted tracked files.&lt;/p&gt;

&lt;h3&gt;
  
  
  History
&lt;/h3&gt;

&lt;p&gt;To see a list of all your saves&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Difference
&lt;/h3&gt;

&lt;p&gt;Before you stage or commit, you should always check what you actually changed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git diff
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Branching
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Create Branch
&lt;/h3&gt;

&lt;p&gt;By default, we are on the &lt;code&gt;main&lt;/code&gt; (or &lt;code&gt;master&lt;/code&gt;) branch. Let's create a new timeline:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git branch dark-mode-feature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Switching Branches
&lt;/h3&gt;

&lt;p&gt;Now we can switch to our new branch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout dark-mode-feature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Newer Git versions also support &lt;code&gt;git switch dark-mode-feature&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Merging
&lt;/h3&gt;

&lt;p&gt;You wrote your code in &lt;code&gt;dark-mode-feature&lt;/code&gt;, committed it, and tested it. It works! Now you want to merge it back into the &lt;code&gt;main&lt;/code&gt; branch.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Switch back to main: &lt;code&gt;git checkout main&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Merge the feature: &lt;code&gt;git merge dark-mode-feature&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Going Remote
&lt;/h2&gt;

&lt;p&gt;So far, everything has happened on your computer (Local). To share code, we need a Remote repository.&lt;/p&gt;

&lt;h3&gt;
  
  
  Clone
&lt;/h3&gt;

&lt;p&gt;Download existing Repo to local&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone &amp;lt;url&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Push
&lt;/h3&gt;

&lt;p&gt;Upload local commits to remote Repo&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Pull
&lt;/h3&gt;

&lt;p&gt;Download new changes from cloud to local computer&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git pull
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Corporate Kit
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Stash
&lt;/h3&gt;

&lt;p&gt;You are working on a new feature (messy code, half-broken). Suddenly, your boss says, &lt;em&gt;"Critical bug! Fix it now!"&lt;/em&gt; You can't switch branches because your work isn't done, but you can't commit it yet either. We want to put our changes in a temporary storage drawer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Pop Stash
&lt;/h3&gt;

&lt;p&gt;To get your stash back&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash pop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Reset
&lt;/h3&gt;

&lt;p&gt;Sometimes you commit too early and want to go back. &lt;code&gt;git reset&lt;/code&gt; lets you move back to provided commit, but it comes in two flavors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Soft Reset:&lt;/strong&gt; Undoes the commit but &lt;strong&gt;keeps your code changes&lt;/strong&gt; in the staging area.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Go one commit back (keep changes staged)&lt;/span&gt;
git reset &lt;span class="nt"&gt;--soft&lt;/span&gt; HEAD~1

&lt;span class="c"&gt;# Go one commit back (keep changes unstaged) - mixed reset&lt;/span&gt;
git reset HEAD~1

&lt;span class="c"&gt;# Go to a specific commit&lt;/span&gt;
git reset &amp;lt;commitHash&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Hard Reset:&lt;/strong&gt; Undoes the commit and deletes all changes. It reverts everything to exactly how it was before you started working.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Go one commit back (delete commit + delete changes)&lt;/span&gt;
git reset &lt;span class="nt"&gt;--hard&lt;/span&gt; HEAD~1

&lt;span class="c"&gt;# Go to a specific commit (delete all changes)&lt;/span&gt;
git reset &lt;span class="nt"&gt;--hard&lt;/span&gt; &amp;lt;commitHash&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Warning: This deletes your work permanently. Burning the bridge behind you. There is no going back.&lt;/p&gt;

&lt;h3&gt;
  
  
  Revert
&lt;/h3&gt;

&lt;p&gt;You already pushed bad code to the shared &lt;code&gt;main&lt;/code&gt; branch. You &lt;strong&gt;cannot&lt;/strong&gt; use &lt;code&gt;reset&lt;/code&gt; (because deleting history that others have downloaded will cause conflicts for other developers). Create a &lt;em&gt;new&lt;/em&gt; commit that does the exact opposite of the bad commit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git revert &amp;lt;commit-id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Git Cherry-Pick
&lt;/h3&gt;

&lt;p&gt;Your teammate is working on a huge Experimental branch with 50 commits. They fixed a tiny bug in &lt;em&gt;one&lt;/em&gt; of those commits. You want that bug fix, but you &lt;em&gt;don't&lt;/em&gt; want the rest of their experimental code. Pick just that one commit and apply it to your branch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git cherry-pick &amp;lt;commit-id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Rebase
&lt;/h3&gt;

&lt;p&gt;You are working on a feature branch. Meanwhile, the main team has added 10 new updates. Your branch is now out of date. Instead of a messy merge, you &lt;strong&gt;rebase&lt;/strong&gt;. This picks up your work and places it on &lt;em&gt;top&lt;/em&gt; of the latest code, keeping the history in a straight line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git rebase main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Tip
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;In case of fire: &lt;code&gt;git commit&lt;/code&gt;, &lt;code&gt;git push&lt;/code&gt;, leave building.&lt;br&gt;&lt;br&gt;
— Anonymous Developer&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>git</category>
    </item>
    <item>
      <title>Git The Game Changer</title>
      <dc:creator>Satpalsinh Rana</dc:creator>
      <pubDate>Sun, 28 Dec 2025 11:09:34 +0000</pubDate>
      <link>https://forem.com/satpalsinhrana/git-the-game-changer-17b7</link>
      <guid>https://forem.com/satpalsinhrana/git-the-game-changer-17b7</guid>
      <description>&lt;h2&gt;
  
  
  The Tale of the Overwritten Code
&lt;/h2&gt;

&lt;p&gt;Once upon a time, there were two frontend developers, Jon and Arya, working on the launch website for "Winterfell Watch."&lt;/p&gt;

&lt;p&gt;Jon was responsible for styling the new "Hero Section" (the big banner at the top). Arya was responsible for the "Contact Form" at the bottom.&lt;/p&gt;

&lt;p&gt;It was Friday night, and the Martin wanted the site live by morning.&lt;/p&gt;

&lt;p&gt;The Handoff Jon finished the Hero Section. It looked majestic with a new bold font. He felt good. He compressed the folder and named it: 📁 &lt;em&gt;Winterfell_final.zip&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;He emailed it to Arya so she could add her work.&lt;/p&gt;

&lt;p&gt;The Fix Arya downloaded Jon's zip file. She started working on her part. She noticed the Contact Form submit button was broken (🐛). She wrote the JavaScript to fix it. While she was there, she also adjusted the padding on the footer.&lt;/p&gt;

&lt;p&gt;She saved her work, zipped the whole project, and named it: 📁 &lt;em&gt;Winterfell_Arya_Fixed.zip&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;She emailed it back to Jon and went to grab a coffee.&lt;/p&gt;

&lt;p&gt;The Disaster Strikes Jon received the email, but before he opened it, he noticed a typo in his Hero Section headline.&lt;/p&gt;

&lt;p&gt;“I’ll just fix this quickly on my local copy before I merge Arya’s stuff,” he thought.&lt;/p&gt;

&lt;p&gt;He opened the folder on his desktop (his version, before Arya’s fix). He fixed the typo. Then, thinking he was being efficient, he simply dragged Arya's folder into his, clicked "Replace All" to get her files, and then... he hesitated.&lt;/p&gt;

&lt;p&gt;He realized his styles.css was newer than hers because he just fixed the typo. So he chose "Keep My File" for the stylesheet.&lt;/p&gt;

&lt;p&gt;He zipped the result as: 📁 &lt;em&gt;Winterfell_Launch.zip&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The Result They deployed the site.&lt;/p&gt;

&lt;p&gt;The Good: Jon’s typo was fixed.&lt;/p&gt;

&lt;p&gt;The Bad: Because Jon kept his version of the stylesheet, Arya’s footer padding changes were deleted.&lt;/p&gt;

&lt;p&gt;The Ugly: Because of the messy copy-paste, the JavaScript file linking broke. The Contact Form didn't work at all.&lt;/p&gt;

&lt;p&gt;The Backup Nightmare Jon looked at his desktop. It was a graveyard of zip files.&lt;/p&gt;

&lt;p&gt;He had no idea which folder contained the working Contact Form code. He had overwritten Arya's bug fix with his typo fix.&lt;/p&gt;

&lt;p&gt;The Realization Arya stared at the broken form and sighed. "Jon, we are professional developers. We shouldn't be emailing zip files like it's 300 AC. We need a way to merge my footer and your header without erasing each other."&lt;/p&gt;

&lt;h2&gt;
  
  
  The Single Source of Truth
&lt;/h2&gt;

&lt;p&gt;After the "Launch Ready" disaster, Jon and Arya realized the root of their problem wasn't bad luck it was bad architecture.&lt;/p&gt;

&lt;p&gt;They had been operating with Two Sources of Truth: &lt;strong&gt;Jon’s laptop&lt;/strong&gt; (which believed the Hero Section was most important) and &lt;strong&gt;Arya’s laptop&lt;/strong&gt; (which believed the Contact Form fix was most important).&lt;/p&gt;

&lt;p&gt;Here comes our savior 🧑‍💻 &lt;strong&gt;“The mindful engineers of the world“ who&lt;/strong&gt; introduced the version control system.&lt;/p&gt;

&lt;h3&gt;
  
  
  Local Version Control
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Concept:&lt;/strong&gt; Engineers created a local database on their computer that stored changes to files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; If Jon wanted to share code with Arya, he still had to email it. It solved the "Undo" problem, but not the "Collaboration" problem.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Centralized Version Control
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Concept: It contains a single server which stores the changes to files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Problem: Single point of failure. If Night king attacks the server it will go down. If the central server goes down, nobody can commit or collaborate because the server is the single point of truth.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Distributed Version Control
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Concepts: The code lived everywhere, safely duplicated across the Server and every Local machine.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Example: Git, Mercurial, Fossil, and Bazaar&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  GIT - Time Machine for our code
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Back to our story.
&lt;/h3&gt;

&lt;p&gt;Initialize Repository&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Jon casts a spell on his project folder, transforming it from a normal directory into a repository watched by the Time Machine (GIT).&lt;/p&gt;

&lt;h3&gt;
  
  
  Selection
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Jon tells Git to include “index.html” in his next save point.&lt;br&gt;&lt;br&gt;
Then he created a large number of files and wanted all untracked files to be included in the next save point.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Save Point
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"First Commit by Jon"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Jon created a checkpoint.&lt;/p&gt;

&lt;p&gt;History&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Jon can now see the history of the code changes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sharing
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Jon pushes all his save points to the “The Remote Kingdoms” in night. So, Arya will get an update.&lt;/p&gt;

&lt;h3&gt;
  
  
  Copy
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone &amp;lt;url&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sansa joins the team. She &lt;strong&gt;needs&lt;/strong&gt; a perfect clone of the repository on her device.&lt;/p&gt;

&lt;h3&gt;
  
  
  Update
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git pull
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As Jon pushed all his changes at night in the “The Remote Kingdoms”. In the morning, Arya wants the latest code, so she types pull and get all the save points from the “The Remote Kingdoms”.&lt;/p&gt;

&lt;h3&gt;
  
  
  Parallel Verse
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git branch dark-mode
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sansa wants to work on dark mode. So, she create a branch and checkout to the dark-mode branch and started her work on it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout dark-mode
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Combination
&lt;/h3&gt;

&lt;p&gt;Sansa completed her development and want to merge the Dark Mode back to the main branch.&lt;br&gt;&lt;br&gt;
So she teleport back to main branch and spell below merge command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout main
git merge dark-mode
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Correction
&lt;/h3&gt;

&lt;p&gt;Sansa realizes that there is commit which contains a bug 🐛 in the “Dark Mode” development which was merged.&lt;/p&gt;

&lt;p&gt;But she can’t time travel back (reset) because Arya already downloaded (pulled) the code in her local. So, she decided to revert particular commit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  git revert &amp;lt;commit-id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Time Travel (Handle it carefully)
&lt;/h3&gt;

&lt;p&gt;Jon want to travel back to some a save point (e.g. a1b2c3). He uses the below spell to forcefully &lt;strong&gt;rewind time&lt;/strong&gt; back to that exact moment (a1b2c3). Everything after that moment is erased. Using &lt;code&gt;reset --hard&lt;/code&gt; after sharing code (push) is dangerous because it rewrites history and can break everyone’s repo.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reset &lt;span class="nt"&gt;--hard&lt;/span&gt; &amp;lt;commit-id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Remote Kingdoms
&lt;/h2&gt;

&lt;p&gt;Once Jon, Sansa and Arya learned to push their code to the cloud, Robb revealed a secret of remote kingdoms and their kings:&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;GitHub (The Kingdom of Open Source)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The largest kingdom in the realm. Developers across the Seven Kingdoms gather here, creating alliances through Pull Requests and winning glory with Stars.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;GitLab (The Fortress of DevOps)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A more disciplined kingdom. Known for pipelines, CI/CD dragons, and strict military formations.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Bitbucket (The House of Private Repositories)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A quieter, more introverted kingdom. Mostly favored by the Houses of Atlassian and Jira Knights.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deep Dive
&lt;/h2&gt;

&lt;p&gt;Once Jon asks Robb, “Where does this Time Machine GIT actually live? Is it magic?"&lt;/p&gt;

&lt;p&gt;Robb opened a project folder and enabled “Show hidden files”. There, sitting quietly at the top, was a folder named 📁 &lt;strong&gt;.git .&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;Let’s open this folder and see how the engine works.&lt;/p&gt;

&lt;h3&gt;
  
  
  HEAD (You are here)
&lt;/h3&gt;

&lt;p&gt;Open file in notepad, it contains something like: &lt;code&gt;ref: refs/heads/master&lt;/code&gt;. It tells Git where you currently are. When Jon teleports using &lt;code&gt;git checkout dark-mode&lt;/code&gt;, Git updates this file to point to the dark-mode branch and now it would contains &lt;code&gt;ref: refs/heads/dark-mode&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  objects/ (The Database)
&lt;/h3&gt;

&lt;p&gt;It’s the storage space for Git. It stores blobs, trees, and commits, each named after their SHA-1 hash.&lt;/p&gt;

&lt;p&gt;So, when Sansa takes a snapshot git commit then git compress, calculates their unique ID, and throws them into this bucket.&lt;/p&gt;

&lt;p&gt;If you want to read file use below command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git cat-file &lt;span class="nt"&gt;-p&lt;/span&gt; &amp;lt;object-id&amp;gt;
&lt;span class="c"&gt;# cat-file: "Show me the file."&lt;/span&gt;
&lt;span class="c"&gt;# -p: "Pretty-print it" (Make it human-readable).&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tree 8d3a1...
parent 1f4e2...
author Jon Snow &amp;lt;jon.dev@winterfell.com&amp;gt; 1703865000 +0000

Created the homepage hero section
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  refs/ (Bookmarks)
&lt;/h3&gt;

&lt;p&gt;This folder stores your Branches and Tags.&lt;/p&gt;

&lt;p&gt;When Sansa created a branch named &lt;code&gt;dark-mode&lt;/code&gt;, Git simply creates a new file in this folder named &lt;code&gt;dark-mode&lt;/code&gt; and writes the current Commit ID inside it.&lt;/p&gt;

&lt;h3&gt;
  
  
  config (Project Settings)
&lt;/h3&gt;

&lt;p&gt;This is where your local settings for your project live.&lt;/p&gt;

&lt;h3&gt;
  
  
  index (Staging Area)
&lt;/h3&gt;

&lt;p&gt;When Jon types &lt;code&gt;git add&lt;/code&gt;, Git updates this &lt;code&gt;index&lt;/code&gt; file to build the list of what will be in the next save point.&lt;/p&gt;

&lt;h2&gt;
  
  
  Moral of the Story
&lt;/h2&gt;

&lt;p&gt;And so, with Git guarding their code like a sworn member of the Night’s Watch, Jon, Arya, and Sansa finally worked together without accidentally destroying each other’s changes.&lt;/p&gt;

&lt;p&gt;They no longer feared overwritten files, broken features, or mysterious zip-file dragons lurking on their desktops.&lt;br&gt;&lt;br&gt;
Every change had a history.&lt;br&gt;&lt;br&gt;
Every branch had a purpose.&lt;br&gt;&lt;br&gt;
Every mistake had a safe way back.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Great teams don’t just write good code, they protect it with good practices.&lt;br&gt;&lt;br&gt;
And Git is the shield that keeps chaos beyond the Wall.&lt;/p&gt;
&lt;/blockquote&gt;

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