<?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[MS Dev]]></title><description><![CDATA[MS Dev]]></description><link>https://blog.ms-dev.me</link><generator>RSS for Node</generator><lastBuildDate>Tue, 14 Apr 2026 20:05:53 GMT</lastBuildDate><atom:link href="https://blog.ms-dev.me/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Python - Immutable & Mutable]]></title><description><![CDATA[🔒 What is Immutability in Python?
Immutability means something that cannot be changed after it's created.In Python, strings, integers, tuples, etc. are immutable types.
When you create a string and assign it to a variable, that string cannot be chan...]]></description><link>https://blog.ms-dev.me/python-immutable-mutable</link><guid isPermaLink="true">https://blog.ms-dev.me/python-immutable-mutable</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Python]]></category><category><![CDATA[immutable]]></category><category><![CDATA[Python immutable objects reference]]></category><dc:creator><![CDATA[MRUTYUNJAYA SAHOO]]></dc:creator><pubDate>Thu, 17 Jul 2025 18:13:48 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1752762873968/48aa9e84-3c74-4528-8e7e-b5fa7977d3bd.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-immutability-in-python">🔒 What is Immutability in Python?</h2>
<p>Immutability means <strong>something that cannot be changed after it's created</strong>.<br />In Python, <strong>strings</strong>, <strong>integers</strong>, <strong>tuples</strong>, etc. are <strong>immutable</strong> types.</p>
<p>When you create a string and assign it to a variable, that string cannot be changed—any change results in the creation of a <strong>new object</strong> in memory.</p>
<h2 id="heading-how-python-stores-variables-in-memory">🧠 How Python Stores Variables in Memory</h2>
<p>Think of a variable like a <strong>label or pointer</strong> 🏷️ that sticks to a value stored somewhere in memory (💾). When you assign a value to a variable, Python makes that variable point to a memory location that holds the actual value.</p>
<h3 id="heading-example">Example:</h3>
<pre><code class="lang-python">username = <span class="hljs-string">"msahoo"</span>
</code></pre>
<p>At this point, Python stores the string <code>"msahoo"</code> in memory, and the variable <code>username</code> simply <strong>points</strong> to that memory location.</p>
<p>📌 Now <code>username → "msahoo"</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752770174174/edafaac5-610b-4ddc-9dc0-eebcf6b73cf5.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-what-happens-when-you-reassign-an-immutable-variable">🔁 What Happens When You Reassign an Immutable Variable?</h2>
<p>Let’s see what happens if we reassign the variable:</p>
<pre><code class="lang-python">username = <span class="hljs-string">"hello"</span>
</code></pre>
<p>Here’s the magic of immutability:</p>
<ul>
<li><p>Python <strong>doesn't change</strong> the original <code>"msahoo"</code> string.</p>
</li>
<li><p>Instead, it <strong>creates a new string object</strong> <code>"hello"</code> in memory.</p>
</li>
<li><p>Then, it <strong>re-points</strong> the <code>username</code> variable to this new string.</p>
</li>
</ul>
<p>So:</p>
<ul>
<li><p>Before: <code>username → "msahoo"</code></p>
</li>
<li><p>After: <code>username → "hello"</code></p>
</li>
</ul>
<p>🧠 The <code>"msahoo"</code> string is still sitting in memory—but no variable is pointing to it now.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752770141207/c7df0f80-cb38-4411-8493-ec66b0064a58.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-memory-reference-flow-visual-explanation">🔄 Memory Reference Flow (Visual Explanation)</h2>
<p>Your example in the image is a perfect representation of how it works:</p>
<h3 id="heading-step-1">Step 1:</h3>
<pre><code class="lang-python">username = <span class="hljs-string">"msahoo"</span>
</code></pre>
<p>📌 Memory:</p>
<pre><code class="lang-python">username ───▶ <span class="hljs-string">"msahoo"</span>
</code></pre>
<h3 id="heading-step-2">Step 2:</h3>
<pre><code class="lang-python">username = <span class="hljs-string">"hello"</span>
</code></pre>
<p>📌 Memory:</p>
<pre><code class="lang-python">username ───▶ <span class="hljs-string">"hello"</span>
<span class="hljs-string">"msahoo"</span> (orphaned, waiting <span class="hljs-keyword">for</span> garbage collection)
</code></pre>
<h2 id="heading-pythons-garbage-collection">🧹 Python’s Garbage Collection (🗑️)</h2>
<p>Once a value (like <code>"msahoo"</code>) is no longer referenced by any variable, Python’s <strong>garbage collector</strong> will clean it up automatically.</p>
<p>You don’t have to manually delete it—Python handles it for you in the background. That’s why we say Python has <strong>automatic memory management</strong>.</p>
<h2 id="heading-why-is-immutability-important">💡 Why is Immutability Important?</h2>
<p>Here’s why Python makes some objects immutable:</p>
<ul>
<li><p>✅ <strong>Safety</strong>: No one can change the object by mistake.</p>
</li>
<li><p>⚡ <strong>Performance</strong>: Immutable objects are optimized internally.</p>
</li>
<li><p>🧵 <strong>Thread-Safe</strong>: Multiple parts of the code can use the same immutable object without issues.</p>
</li>
</ul>
<p>It’s like working with a locked file (🔒)—you can read it, but you can't write over it.</p>
<h2 id="heading-final-recap-with-code">🧪 Final Recap with Code:</h2>
<pre><code class="lang-python">username = <span class="hljs-string">"msahoo"</span> <span class="hljs-comment"># step 1 - new string created</span>
username = <span class="hljs-string">"hello"</span> <span class="hljs-comment"># step 2 - new string created, old one orphaned</span>
</code></pre>
<ul>
<li><p><code>"msahoo"</code> and <code>"hello"</code> are <strong>two different objects</strong>.</p>
</li>
<li><p><code>username</code> just <strong>points to different objects</strong> in different steps.</p>
</li>
<li><p>Old object gets <strong>garbage collected</strong> if nothing points to it.</p>
</li>
</ul>
<h2 id="heading-why-are-we-saying-object-and-not-variable">❓ Why are we saying “object” and not “variable”?</h2>
<p>In Python, <strong>everything is an object</strong>—strings, numbers, lists, etc.<br />A <strong>variable</strong> is just a <strong>label</strong> that refers to an object.</p>
<p>So, when we say:</p>
<blockquote>
<p>“Immutable object is thread-safe,”<br />we mean:<br />“The actual thing in memory (like a string or number) is safe to share between threads because it can’t be modified.”</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Python Inner Working]]></title><description><![CDATA[What is python?
Python is like a bridge between human thinking and computer logic. It’s a language that doesn’t try to complicate things — instead, it lets you express ideas in code almost as naturally as you think them.
It feels more like writing in...]]></description><link>https://blog.ms-dev.me/python-inner-working</link><guid isPermaLink="true">https://blog.ms-dev.me/python-inner-working</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Python]]></category><category><![CDATA[Python Internal Working]]></category><category><![CDATA[beginner]]></category><dc:creator><![CDATA[MRUTYUNJAYA SAHOO]]></dc:creator><pubDate>Mon, 14 Jul 2025 20:58:03 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1752526635842/831992a3-ce53-4bed-a962-b7b6ac658b02.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-python">What is python?</h2>
<p><strong>Python is like a bridge between human thinking and computer logic</strong>. It’s a language that doesn’t try to complicate things — instead, it lets you express ideas in code almost as naturally as you think them.</p>
<p>It feels more like writing instructions to a smart friend than programming a machine. You don’t have to worry much about complex syntax or structure — you focus on what you want to build.</p>
<p>Whether it’s analyzing huge datasets, building websites, or training AI</p>
<p><strong>Professionally speaking, Python is:</strong></p>
<ul>
<li><p><strong>Dynamically typed</strong> – you don’t need to declare variable types.</p>
</li>
<li><p><strong>Interpreted</strong> – it runs line by line through an interpreter.</p>
</li>
<li><p><strong>Multi-paradigm</strong> – supports object-oriented, procedural, and functional programming styles.</p>
</li>
<li><p><strong>Extremely flexible</strong> – widely used in automation, data science, machine learning, web development, scripting, software testing, and more.</p>
</li>
</ul>
<h3 id="heading-inside-python-what-really-happens-behind-the-scenes">🔍 <strong>Inside Python: What Really Happens Behind the Scenes?</strong></h3>
<p>Have you ever wondered <em>how</em> Python understands your code? You write simple lines like <code>print("Hello, world!")</code>, but under the hood, Python is doing a lot of heavy lifting — from compiling to bytecode to memory management and more.<br />In this blog, we’ll take a beginner-friendly peek into the engine room of Python. No complex jargon, just a clear and curious exploration of how your favorite language really works.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752505863830/f7cc2ab3-2e63-40b7-b354-d5abc4da16d7.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-how-python-runs-your-code-step-by-step"><strong>How Python Runs Your Code: Step-by-Step</strong></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752514126928/51d295b7-fae9-4ff6-a4aa-b5dbda7c2f8a.gif" alt class="image--center mx-auto" /></p>
<p>Have you ever wondered what happens behind the scenes when you run a Python program? Let’s break down the journey of a simple script, for example:</p>
<pre><code class="lang-python">print(<span class="hljs-string">"Hello, world!"</span>)
</code></pre>
<p>From the moment you <strong>write the code</strong> to when <strong>“Hello, world!”</strong> appears on your screen, Python goes through several stages. We’ll walk through each stage in clear terms.</p>
<h3 id="heading-1code-editor"><strong>1.</strong>✍️<strong>Code Editor</strong></h3>
<p>First, you write your code in a <strong>code editor</strong> or <strong>IDE</strong> (like VS Code, PyCharm, Jupyter Notebook or even a simple text editor). The editor is just a tool where you type your Python commands. In our example, the editor window contains:</p>
<pre><code class="lang-python">print(<span class="hljs-string">"Hello, world!"</span>)
</code></pre>
<p>This is the human-readable code you wrote. At this point, <strong>nothing is happening yet to run the code</strong> – the code just lives in the editor. When you save the file, you choose a filename with a <code>.py</code> extension (for example, <code>hello.py</code>). This saved file is where your code is stored for Python to use.</p>
<h3 id="heading-2-source-file-py"><strong>2.</strong> 📄<strong>Source File (.py)</strong></h3>
<p>When you save your code, it becomes a <strong>Python source file</strong> (for example, <code>hello.py</code>). This file contains the exact text you wrote – in this case, the line <code>print("hello python")</code>. The source file is just plain text on your disk. Computers can’t execute this text directly because they only understand machine code (binary instructions)</p>
<p>Instead, Python reads this file as input. The source file is like a recipe written in English – it tells the computer <em>what</em> to do, but it’s not in the computer’s native language yet. For instance, our <code>hello.py</code> file has one line of code that tells Python to print a greeting.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752519469665/cc04b560-f0f2-45e4-8a93-18523efc572f.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-3-compiler"><strong>3.</strong> 🧰<strong>Compiler</strong></h3>
<p>Next, when you <strong>run</strong> the Python program (for example by typing <code>python hello.py</code> in a terminal) or directly click the run button in VS Code, the Python interpreter takes over. Python is often called an <em>interpreted</em> language, but under the hood, it does a <strong>compilation step</strong> first. The interpreter (such as CPython) takes your <code>.py</code> source file and <strong>compiles it into</strong> bytecode.</p>
<p>This means Python checks your code for errors and transforms it into a lower-level form. In our example, <code>print("hello python")</code> is converted into <strong>Python Bytecode</strong>. At the same time, Python may create a compiled file named something like <code>hello.cpython-311.pyc</code> inside a <code>__pycache__</code> folder (the number matches your Python version). This <code>.pyc</code> file stores the <strong>bytecode</strong> so Python can run your code faster next time.</p>
<p>In simple terms, the compiler in python translates your readable code into bytecode- an intermediate form that the Python Virtual Machine (PVM) can understand.</p>
<h3 id="heading-4-bytecode"><strong>4.</strong> 📦<strong>Bytecode</strong></h3>
<p><strong>Bytecode</strong> is the result of the compilation step. It’s a set of instructions, but not quite machine code. Think of bytecode as <strong>Python’s own low-level language</strong>. It’s still not directly understandable by the CPU, but it’s much closer to what the computer can execute compared to your original text. Bytecode is platform-independent, which means the same bytecode can run on any operating system that has the same Python interpreter.</p>
<p>For our <code>print("hello python")</code> example, Python might generate bytecode instructions like load the string <em>“hello python”</em> and <em>“call the print function”</em>. You don’t usually see this bytecode, but it’s saved in a <code>.pyc</code> file inside a <code>__pycache__</code> folder. The <code>__pycache__</code> folder is Python’s way of caching compiled bytecode files. On later runs, Python will use this cached bytecode (if the source hasn’t changed) to start your program more quickly.</p>
<p>In summary, <strong>bytecode</strong> is an intermediate, “almost machine” code that Python will execute. It’s saved in <code>.pyc</code> files in a special folder (<code>__pycache__</code>).</p>
<p>e.g.: I create a file named <code>test_hello.py</code>. Here you can see I imported the <code>hello.py</code> file to <code>test_hello.py</code> file then I hit run button after that a <code>__pycache__</code> folder created.</p>
<blockquote>
<p><em>💡 For example, importing a file named</em> <code>helper.py</code> <em>will generate a compiled file like</em> <code>hello.cpython-313.pyc</code><em>.</em></p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752519015200/6ae7a8b6-aeaa-4024-bb62-8c4992e1d398.png" alt class="image--center mx-auto" /></p>
<p><strong>🗂️ Why __pycache__?</strong></p>
<p>Python uses the <code>__pycache__</code> folder to <strong>keep things organized and clean</strong>. If every <code>.pyc</code> file were saved in the main directory, your project folder would quickly become messy — especially in larger applications with dozens of modules.</p>
<h3 id="heading-5-python-virtual-machine"><strong>5.</strong> 🖥️<strong>Python Virtual Machine</strong></h3>
<p>Once the bytecode is ready, it’s time for the real work to happen — and that’s where the <strong>Python Virtual Machine (PVM)</strong> comes in.</p>
<p>The PVM is a <strong>software-based engine</strong> that gets installed automatically when you install Python. You don’t need to install it separately — it’s already bundled in your Python distribution. You can think of it as an engine that executes the bytecode instructions one by one. The PVM loads the bytecode (from the <code>.pyc</code> file or directly from memory) and then enters a loop: it reads each bytecode instruction, decodes it, and performs the corresponding action.</p>
<p><strong>🔁 The Loop That Runs Your Code:</strong></p>
<p>Inside the PVM, there’s a <strong>loop running continuously</strong>. This loop is the heart of the interpreter. When you push a <code>.pyc</code> bytecode file into it (via imports or running Python code), the PVM starts <strong>executing the bytecode instructions line by line</strong>.</p>
<blockquote>
<p>That’s exactly why Python is known as an <strong>interpreted language</strong> — because this loop acts like an interpreter that runs your code step-by-step, not all at once like in compiled languages.</p>
</blockquote>
<p>The PVM is also referred to as Python’s <strong>runtime engine</strong> — a necessary software component without which the code simply won’t run. Every programming language has its own runtime:</p>
<ul>
<li><p>Java has the <strong>JVM (Java Virtual Machine)</strong></p>
</li>
<li><p>JavaScript has <strong>V8 Engine</strong></p>
</li>
<li><p>Python has the <strong>PVM</strong></p>
</li>
</ul>
<p>Without this runtime engine, even compiled bytecode (.pyc) would just sit there — doing nothing. The PVM is the one that takes action and produces the output you see.</p>
<p><strong>So in short:</strong><br />🧠 <strong>PVM is the brain behind Python execution.</strong> It reads bytecode, runs a loop internally, and line-by-line brings your code to life.</p>
<h3 id="heading-6-running-program"><strong>6.</strong> 🚀<strong>Running Program</strong></h3>
<p>Finally, after the PVM executes the instructions, you see the result. In our example, the bytecode was telling Python to print text to the screen. The PVM runs the <code>print</code> function, which sends <code>"Hello, world!"</code> to the standard output (your console or terminal). The user (you) then sees: appear on the screen. This is the running program’s output.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752524575069/b715e593-251b-451f-ab08-77dc8a01fe89.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-conclusion-python-does-the-heavy-lifting-for-you"><strong>🎯 Conclusion: Python Does the Heavy Lifting for You</strong></h3>
<p>You write simple code like <code>print("hello python")</code> — but behind the scenes, Python sets an entire system in motion. From compiling your code to bytecode, organizing it smartly in <code>__pycache__</code>, and finally running it through the powerful Python Virtual Machine — Python handles all the complex stuff so you don’t have to.</p>
<p>That’s the beauty of Python:<br />👉 <strong>It’s simple on the surface, but powerful underneath.</strong><br />All you need to do is write — Python takes care of the rest.</p>
]]></content:encoded></item><item><title><![CDATA[Array Methods in JavaScript]]></title><description><![CDATA[What is an Array?
In JS, an array is an ordered list of values. You can think of it as a collection of items, stored in a linear format — like boxes arranged in a single row, each holding a piece of data.
In JavaScript, arrays are dynamic. This means...]]></description><link>https://blog.ms-dev.me/array-methods</link><guid isPermaLink="true">https://blog.ms-dev.me/array-methods</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[array]]></category><category><![CDATA[array methods]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[webdev]]></category><category><![CDATA[webdevcohort]]></category><dc:creator><![CDATA[MRUTYUNJAYA SAHOO]]></dc:creator><pubDate>Mon, 09 Jun 2025 19:54:25 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1749498690448/476bfd15-40d3-478f-8bcc-5f5a31baef40.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-an-array">What is an Array?</h2>
<p>In JS, an array is an ordered list of values. You can think of it as a <strong>collection of items</strong>, stored in a <strong>linear</strong> format — like boxes arranged in a single row, each holding a piece of data.</p>
<p>In JavaScript, arrays are <strong>dynamic</strong>. This means:</p>
<ul>
<li><p>You don’t need to define how many items it will hold in advance.</p>
</li>
<li><p>You can <strong>add</strong> or <strong>remove</strong> items anytime — the size of the array changes automatically.</p>
</li>
</ul>
<p>Here's a simple example of an array:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> fruits = [<span class="hljs-string">"apple"</span>, <span class="hljs-string">"banana"</span>, <span class="hljs-string">"mango"</span>];
</code></pre>
<p>In the example above, <code>fruits</code> is an array holding three items: <code>"apple"</code>, <code>"banana"</code>, and <code>"mango"</code>.</p>
<p>Each item in an array is stored in a position called an <strong>index</strong>, and indexing starts from <strong>0</strong>.</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">console</span>.log(fruits[<span class="hljs-number">0</span>]); <span class="hljs-comment">// Output: apple</span>
<span class="hljs-built_in">console</span>.log(fruits[<span class="hljs-number">1</span>]); <span class="hljs-comment">// Output: banana</span>
</code></pre>
<h3 id="heading-array-methods">……………………………………. Array Methods …………………………………………</h3>
<h3 id="heading-1-push-add-to-the-end">1. <code>push()</code> – Add to the End</h3>
<p>The <code>push()</code> method is used to <strong>add one or more items to the end</strong> of an array.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> fruits = [<span class="hljs-string">"apple"</span>, <span class="hljs-string">"banana"</span>];
fruits.push(<span class="hljs-string">"mango"</span>);

<span class="hljs-built_in">console</span>.log(fruits); <span class="hljs-comment">// Output: ["apple", "banana", "mango"]</span>
</code></pre>
<p>👉 It updates the original array and also returns the <strong>new length</strong> of the array.</p>
<h3 id="heading-2-pop-remove-from-the-end">2. <code>pop()</code> – Remove from the End</h3>
<p>The <code>pop()</code> method is used to <strong>remove the last item</strong> from the array.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> fruits = [<span class="hljs-string">"apple"</span>, <span class="hljs-string">"banana"</span>, <span class="hljs-string">"mango"</span>];
fruits.pop();

<span class="hljs-built_in">console</span>.log(fruits); <span class="hljs-comment">// Output: ["apple", "banana"]</span>
</code></pre>
<p>👉 It returns the <strong>item that was removed</strong>.</p>
<h3 id="heading-3-unshift-add-to-the-beginning">3. <code>unshift()</code> – Add to the Beginning</h3>
<p>The <code>unshift()</code> method is used to <strong>add one or more items at the beginning</strong> of the array.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> fruits = [<span class="hljs-string">"banana"</span>, <span class="hljs-string">"mango"</span>];
fruits.unshift(<span class="hljs-string">"apple"</span>);

<span class="hljs-built_in">console</span>.log(fruits); <span class="hljs-comment">// Output: ["apple", "banana", "mango"]</span>
</code></pre>
<p>👉 Like <code>push()</code>, it returns the <strong>new length</strong> of the array.</p>
<h3 id="heading-4-shift-remove-from-the-beginning">4. <code>shift()</code> – Remove from the Beginning</h3>
<p>The <code>shift()</code> method is used to <strong>remove the first item</strong> from the array.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> fruits = [<span class="hljs-string">"apple"</span>, <span class="hljs-string">"banana"</span>, <span class="hljs-string">"mango"</span>];
fruits.shift();

<span class="hljs-built_in">console</span>.log(fruits); <span class="hljs-comment">// Output: ["banana", "mango"]</span>
</code></pre>
<p>👉 It returns the <strong>item that was removed</strong>.</p>
<h3 id="heading-5-includes-is-the-item-present">5. <code>includes()</code> – Is the Item Present?</h3>
<p>The <code>includes()</code> method is used to <strong>check whether a specific item exists in the array or not</strong>. It returns:</p>
<ul>
<li><p><code>true</code> if the item is found</p>
</li>
<li><p><code>false</code> if the item is not found</p>
</li>
</ul>
<p>✅ Useful for <strong>"yes or no"</strong> type questions.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> fruits = [<span class="hljs-string">"apple"</span>, <span class="hljs-string">"banana"</span>, <span class="hljs-string">"mango"</span>];

<span class="hljs-built_in">console</span>.log(fruits.includes(<span class="hljs-string">"banana"</span>)); <span class="hljs-comment">// Output: true</span>
<span class="hljs-built_in">console</span>.log(fruits.includes(<span class="hljs-string">"grapes"</span>)); <span class="hljs-comment">// Output: false</span>
</code></pre>
<h3 id="heading-6-indexof-where-is-the-item">6. <code>indexOf()</code> – Where is the Item?</h3>
<p>The <code>indexOf()</code> method tells you <strong>the index (position)</strong> of an item in the array.</p>
<ul>
<li><p>If the item is found, it returns the <strong>index number</strong> (starting from 0).</p>
</li>
<li><p>If the item is not found, it returns <strong>-1</strong>.</p>
</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> fruits = [<span class="hljs-string">"apple"</span>, <span class="hljs-string">"banana"</span>, <span class="hljs-string">"mango"</span>];

<span class="hljs-built_in">console</span>.log(fruits.indexOf(<span class="hljs-string">"banana"</span>)); <span class="hljs-comment">// Output: 1</span>
<span class="hljs-built_in">console</span>.log(fruits.indexOf(<span class="hljs-string">"grapes"</span>)); <span class="hljs-comment">// Output: -1</span>
</code></pre>
<p>✅ Useful when you want to <strong>know the position</strong> of an item.</p>
<h3 id="heading-7-join-combine-all-items-into-a-string">7.🔗 <code>join()</code> – Combine All Items into a String</h3>
<p>The <code>join()</code> method is used to <strong>combine all elements of an array into a single string</strong>. By default, the items are joined using <strong>commas</strong>, but you can use any <strong>separator</strong> you like (such as a space, hyphen, or nothing at all).</p>
<p>It does <strong>not change</strong> the original array — it returns a <strong>new string</strong>.</p>
<h3 id="heading-example-1-using-the-default-separator-comma">🧪 Example 1: Using the default separator (comma)</h3>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> fruits = [<span class="hljs-string">"apple"</span>, <span class="hljs-string">"banana"</span>, <span class="hljs-string">"mango"</span>];

<span class="hljs-keyword">let</span> result = fruits.join();
<span class="hljs-built_in">console</span>.log(result); <span class="hljs-comment">// Output: "apple,banana,mango"</span>
</code></pre>
<h3 id="heading-example-2-using-a-custom-separator">🧪 Example 2: Using a custom separator</h3>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> fruits = [<span class="hljs-string">"apple"</span>, <span class="hljs-string">"banana"</span>, <span class="hljs-string">"mango"</span>];

<span class="hljs-keyword">let</span> result = fruits.join(<span class="hljs-string">" - "</span>);
<span class="hljs-built_in">console</span>.log(result); <span class="hljs-comment">// Output: "apple - banana - mango"</span>
</code></pre>
<h3 id="heading-example-3-join-without-any-separator">🧪 Example 3: Join without any separator</h3>
<pre><code class="lang-javascript">javascriptCopy codelet letters = [<span class="hljs-string">"H"</span>, <span class="hljs-string">"e"</span>, <span class="hljs-string">"l"</span>, <span class="hljs-string">"l"</span>, <span class="hljs-string">"o"</span>];

<span class="hljs-keyword">let</span> result = letters.join(<span class="hljs-string">""</span>);
<span class="hljs-built_in">console</span>.log(result); <span class="hljs-comment">// Output: "Hello"</span>
</code></pre>
<p>✅ Use <code>join()</code> when you want to turn an array into a clean, readable string — like creating sentences, formatting data, or displaying items nicely on the screen.</p>
<h3 id="heading-8slice-take-a-piece-without-changing-the-original">8.<code>slice()</code> – Take a Piece (Without Changing the Original)</h3>
<p>The <code>slice()</code> method is used to <strong>extract a portion</strong> of the array and return it as a <strong>new array</strong>.</p>
<ul>
<li><p>It does <strong>not change</strong> the original array.</p>
</li>
<li><p>You provide the <strong>start index</strong> and <strong>end index</strong> (end index is not included).</p>
</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> fruits = [<span class="hljs-string">"apple"</span>, <span class="hljs-string">"banana"</span>, <span class="hljs-string">"mango"</span>, <span class="hljs-string">"grapes"</span>];

<span class="hljs-keyword">let</span> result = fruits.slice(<span class="hljs-number">1</span>, <span class="hljs-number">3</span>);
<span class="hljs-built_in">console</span>.log(result); <span class="hljs-comment">// Output: ["banana", "mango"]</span>
<span class="hljs-built_in">console</span>.log(fruits); <span class="hljs-comment">// Output: ["apple", "banana", "mango", "grapes"]</span>
</code></pre>
<p>🔸 It simply gives you a copy of a selected portion.</p>
<h3 id="heading-9-splice-add-remove-or-replace-changes-original-array">9. <code>splice()</code> – Add, Remove, or Replace (Changes Original Array)</h3>
<p>The <code>splice()</code> method is used to <strong>change the contents</strong> of an array by:</p>
<ul>
<li><p><strong>Removing</strong> items</p>
</li>
<li><p><strong>Adding</strong> new items</p>
</li>
<li><p><strong>Replacing</strong> items</p>
</li>
</ul>
<p>It <strong>does change</strong> the original array.</p>
<p><strong>Syntax:</strong></p>
<pre><code class="lang-javascript">array.splice(start, deleteCount, item1, item2, ...)

<span class="hljs-comment">//✨ Meaning of each part:</span>
<span class="hljs-comment">//start → The index from where you want to start deleting or inserting.</span>
<span class="hljs-comment">//deleteCount → The number of items you want to remove starting from the start index.</span>
<span class="hljs-comment">//item1, item2, ... → Optional. These are the items you want to insert at the start position.</span>
</code></pre>
<h4 id="heading-example-remove-items">🧪 Example: Remove items</h4>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> fruits = [<span class="hljs-string">"apple"</span>, <span class="hljs-string">"banana"</span>, <span class="hljs-string">"mango"</span>, <span class="hljs-string">"grapes"</span>];

fruits.splice(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>); <span class="hljs-comment">// Removes 2 items from index 1</span>
<span class="hljs-built_in">console</span>.log(fruits); <span class="hljs-comment">// Output: ["apple", "grapes"]</span>
</code></pre>
<h4 id="heading-example-add-items">🧪 Example: Add items</h4>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> fruits = [<span class="hljs-string">"apple"</span>, <span class="hljs-string">"grapes"</span>];

fruits.splice(<span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-string">"banana"</span>, <span class="hljs-string">"mango"</span>);
<span class="hljs-built_in">console</span>.log(fruits); <span class="hljs-comment">// Output: ["apple", "banana", "mango", "grapes"]</span>
</code></pre>
<h4 id="heading-example-replace-items">🧪 Example: Replace items</h4>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> fruits = [<span class="hljs-string">"apple"</span>, <span class="hljs-string">"banana"</span>, <span class="hljs-string">"mango"</span>];

fruits.splice(<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-string">"orange"</span>); <span class="hljs-comment">// Replace "banana" with "orange"</span>
<span class="hljs-built_in">console</span>.log(fruits); <span class="hljs-comment">// Output: ["apple", "orange", "mango"]</span>
</code></pre>
<h3 id="heading-helpful-array-methods-for-data-handling">🧹 Helpful Array Methods for Data Handling:</h3>
<p>When working with dynamic data (like from APIs or scraping), it's important to <strong>check data types</strong> and <strong>convert them into arrays</strong> so that we can use array methods on them. Two useful methods are:</p>
<h3 id="heading-10-arrayisarray-check-if-its-an-array">10. <code>Array.isArray()</code> – Check if it’s an Array</h3>
<p>This method is used to <strong>check if a given value is an actual array</strong>. It returns <code>true</code> if the value is an array, otherwise <code>false</code>.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> data = [<span class="hljs-string">"apple"</span>, <span class="hljs-string">"banana"</span>];
<span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">Array</span>.isArray(data));  <span class="hljs-comment">// Output: true</span>

<span class="hljs-keyword">let</span> name = <span class="hljs-string">"apple"</span>;
<span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">Array</span>.isArray(name));  <span class="hljs-comment">// Output: false</span>
</code></pre>
<p>✅ Useful when you're not sure if the data you received is an array — especially in scraped or API data.</p>
<h3 id="heading-11-arrayfrom-convert-to-an-array">11. <code>Array.from()</code> – Convert to an Array</h3>
<p>This method is used to <strong>convert array-like or iterable objects</strong> (like strings, NodeLists, Sets, etc.) into <strong>real arrays</strong>.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> name = <span class="hljs-string">"hello"</span>;
<span class="hljs-keyword">let</span> letters = <span class="hljs-built_in">Array</span>.from(name);

<span class="hljs-built_in">console</span>.log(letters); <span class="hljs-comment">// Output: ["h", "e", "l", "l", "o"]</span>
</code></pre>
<p>Another example — converting a NodeList (which you often get when scraping HTML elements in the browser):</p>
<h4 id="heading-example">🧪 Example:</h4>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> items = <span class="hljs-built_in">document</span>.querySelectorAll(<span class="hljs-string">"p"</span>); <span class="hljs-comment">// This gives a NodeList</span>
<span class="hljs-keyword">let</span> arrayItems = <span class="hljs-built_in">Array</span>.from(items); <span class="hljs-comment">// Now it's a real array</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">Array</span>.isArray(arrayItems)); <span class="hljs-comment">// Output: true</span>
</code></pre>
<p>Now, <code>arrayItems</code> is a <strong>real array</strong>, so you can loop over it, filter it, or map it just like any other array.</p>
<p><strong>💡 Why is this useful?</strong></p>
<p>If you're scraping or collecting multiple elements from the webpage (like all the buttons, headings, or paragraphs), converting them to an array helps you.</p>
<h3 id="heading-powerful-array-methods-in-javascript">🧰 Powerful Array Methods in JavaScript</h3>
<p>When working with arrays, JavaScript gives us some <strong>built-in methods</strong> that make it easier to handle and process data.</p>
<h3 id="heading-12-filter-get-only-what-you-need">12. 🔍 <code>filter()</code> – Get Only What You Need</h3>
<p>The <code>filter()</code> method is used to <strong>filter out</strong> items from an array <strong>based on a condition</strong>.</p>
<p>It does not affect the original array.</p>
<p>✅ It returns a <strong>new array</strong> with only the items that pass the test.</p>
<h4 id="heading-example-1">🧪 Example:</h4>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>];

<span class="hljs-keyword">let</span> evenNumbers = numbers.filter(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">num</span>) </span>{
  <span class="hljs-keyword">return</span> num % <span class="hljs-number">2</span> === <span class="hljs-number">0</span>;
});
<span class="hljs-built_in">console</span>.log(evenNumbers); <span class="hljs-comment">// Output: [2, 4]</span>
</code></pre>
<p><strong>Think of it like</strong>: "Give me only the values that match my condition."</p>
<h3 id="heading-13-foreach-just-loop-through">13. 🔁 <code>forEach()</code> – Just Loop Through</h3>
<p>The <code>forEach()</code> method is used to <strong>loop through</strong> each item in the array and <strong>do something</strong> with it.</p>
<p>✅ It does <strong>not return anything</strong>, it just runs your code for each item.</p>
<h4 id="heading-example-2">🧪 Example:</h4>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> fruits = [<span class="hljs-string">"apple"</span>, <span class="hljs-string">"banana"</span>, <span class="hljs-string">"mango"</span>];

fruits.forEach(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">fruit</span>) </span>{
  <span class="hljs-built_in">console</span>.log(fruit);
});
</code></pre>
<p><strong>Think of it like</strong>: "Go through each item and do this action."</p>
<h3 id="heading-14-map-create-a-new-array-by-changing-each-item">14. 🧪 <code>map()</code> – Create a New Array by Changing Each Item</h3>
<p>The <code>map()</code> method is used to <strong>transform every item</strong> in an array and return a <strong>new array</strong>.</p>
<p>It does not affect the original array.</p>
<p>✅ It’s great when you want to <strong>change</strong> or <strong>modify</strong> the values.</p>
<h4 id="heading-example-3">🧪 Example:</h4>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];

<span class="hljs-keyword">let</span> doubled = numbers.map(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">num</span>) </span>{
  <span class="hljs-keyword">return</span> num * <span class="hljs-number">2</span>;
});
<span class="hljs-built_in">console</span>.log(doubled); <span class="hljs-comment">// Output: [2, 4, 6]</span>
</code></pre>
<p><strong>Think of it like</strong>: "Make a new array by updating each item."</p>
<h3 id="heading-15-reduce-get-a-single-value-from-all-items">15. ➕ <code>reduce()</code> – Get a Single Value from All Items</h3>
<p>The <code>reduce()</code> method is used to <strong>combine all the values</strong> in an array into a <strong>single result</strong>.</p>
<p>The <code>reduce()</code> method is used when you want to take <strong>all values in an array</strong> and reduce them to <strong>a single result</strong> — like <strong>a total price</strong>, <strong>average</strong>, or <strong>sum</strong>.</p>
<blockquote>
<p>ex- Total of a Shopping Cart</p>
</blockquote>
<p>✅ It’s perfect for things like <strong>summing up numbers</strong>, <strong>calculating totals</strong>, etc.</p>
<h4 id="heading-example-shopping-cart-total">🧪 Example: Shopping Cart Total</h4>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> cart = [<span class="hljs-number">100</span>, <span class="hljs-number">200</span>, <span class="hljs-number">150</span>, <span class="hljs-number">50</span>];

<span class="hljs-keyword">let</span> total = cart.reduce(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">acc, current</span>) </span>{
  <span class="hljs-keyword">return</span> acc + current;
}, <span class="hljs-number">0</span>); <span class="hljs-comment">// 0 is the starting value of acc</span>

<span class="hljs-built_in">console</span>.log(total); <span class="hljs-comment">// Output: 500</span>
</code></pre>
<p><strong>💡 How It Works</strong></p>
<p><code>reduce()</code> takes two main things:</p>
<ul>
<li><p><strong>Accumulator</strong> → It stores the result of the previous calculation.</p>
</li>
<li><p><strong>Current value</strong> → The current item in the array.</p>
</li>
</ul>
<p><strong>At first</strong>, the accumulator is set to the initial value you provide (like <code>0</code> for a sum).<br />Then, for <strong>each item</strong>, it updates the accumulator using the current value.</p>
<p>✅ Here's what happens step-by-step:</p>
<ul>
<li><p><code>acc = 0</code>, <code>current = 100</code> → <code>acc = 100</code></p>
</li>
<li><p><code>acc = 100</code>, <code>current = 200</code> → <code>acc = 300</code></p>
</li>
<li><p><code>acc = 300</code>, <code>current = 150</code> → <code>acc = 450</code></p>
</li>
<li><p><code>acc = 450</code>, <code>current = 50</code> → <code>acc = 500</code> ✅ final result</p>
</li>
</ul>
<p><strong>Think of it like</strong>: "Keep combining values to get one final result."</p>
<h2 id="heading-final-thoughts">🎯 Final Thoughts</h2>
<p>Arrays are one of the most powerful tools in JavaScript — and now you’ve unlocked some of their <strong>most useful methods</strong>! From filtering data, transforming values, looping over items, to calculating totals — these methods make your code <strong>cleaner, shorter, and smarter</strong>.</p>
<p>Start practicing them in small projects or while solving real-life problems (like shopping carts, search filters, or list management). The more you use them, the more confident you’ll become.</p>
<p>🚀 So go ahead — experiment, build, and let JavaScript arrays work for you!</p>
]]></content:encoded></item><item><title><![CDATA[Tech Jargon - simplifies complex tech term]]></title><description><![CDATA[🔧 What is Production in Software Development?
When we first build a software project—whether it's a small tool or a big application—we usually create and test it on our own laptop or computer. At this stage, everything works fine because it's just y...]]></description><link>https://blog.ms-dev.me/tech-jargon</link><guid isPermaLink="true">https://blog.ms-dev.me/tech-jargon</guid><category><![CDATA[TechJargon]]></category><category><![CDATA[jargon]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[MRUTYUNJAYA SAHOO]]></dc:creator><pubDate>Wed, 21 May 2025 07:21:36 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1747811723949/a56c8fc7-c8eb-42fb-8b6c-6c1faae94165.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-production-in-software-development">🔧 What is <em>Production</em> in Software Development?</h2>
<p>When we first build a software project—whether it's a small tool or a big application—we usually create and test it on our <strong>own laptop or computer</strong>. At this stage, everything works fine because it's just <strong>you using it</strong>.</p>
<p>But here's the thing:<br />A real-world product is meant to be used by <strong>many people</strong>, not just the developer.</p>
<p>So, once your project is ready, the next step is to <strong>move it from your local machine to a server</strong> where others can access and use it. This process is called <strong>Deployment</strong>, and the environment where the live version runs is known as <strong>Production</strong>.</p>
<hr />
<h3 id="heading-in-simple-words">📌 In Simple Words:</h3>
<blockquote>
<p><strong>Production</strong> is the live version of your software that is available for the <strong>world to use</strong>.</p>
</blockquote>
<hr />
<h3 id="heading-example">💡 Example:</h3>
<ul>
<li><p>You're building a food ordering app on your laptop → Only you can use it.</p>
</li>
<li><p>You deploy it to a web server → Now anyone with the link can place orders.</p>
</li>
<li><p>That deployed version = <strong>Production</strong></p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747811041609/b4d0217e-ab60-4422-ad68-cb0629a9bde0.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[IP Address & DNS]]></title><description><![CDATA[IP Address:
An IP address (Internet Protocol address) is like a home address for your device on the internet. It helps computers and other devices find and communicate with each other.
The URL (like www.chaicode.com) is a human-friendly name, but com...]]></description><link>https://blog.ms-dev.me/ip-dns</link><guid isPermaLink="true">https://blog.ms-dev.me/ip-dns</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[webdev]]></category><category><![CDATA[ip address]]></category><category><![CDATA[dns]]></category><dc:creator><![CDATA[MRUTYUNJAYA SAHOO]]></dc:creator><pubDate>Mon, 19 May 2025 17:53:40 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1747677016758/309d69d0-d13e-4f49-b9ee-15ea85c4d4ca.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-ip-address">IP Address:</h2>
<p>An IP address (Internet Protocol address) is like a home address for your device on the internet. It helps computers and other devices find and communicate with each other.</p>
<p>The URL (like www.chaicode.com) is a human-friendly name, but computers and servers don’t understand it directly. Instead, they rely on IP addresses (like 142.250.183.78 for Google).</p>
<p>e.g. - When you type a URL in your browser:</p>
<ul>
<li><p>Your computer asks a DNS (Domain Name System) to convert that URL into IP address.</p>
</li>
<li><p>Once the IP address is found, your browser connects to the correct server using that IP.</p>
</li>
<li><p>Then the server sends back the requested web page.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744523639628/e428312d-e1ec-491a-aefe-c47204f08aa5.png" alt="IP address Workflow" class="image--center mx-auto" /></p>
<h2 id="heading-dns-domain-name-system">DNS (Domain Name System):</h2>
<p>When we want to open a website, we type a URL (like www.chaicode.com) into the browser. But computers don’t understand names like that — they need a numerical IP address (like 142.250.183.78) to find the website.</p>
<p>Since it's hard for us to remember all these IP addresses, the browser asks a special server called a DNS (Domain Name System).</p>
<p>The DNS server’s job is to take the URL you typed and find the correct IP address for it. Once it gets the IP address, the browser can connect to the website’s server and load the page for you.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744523585475/ada091cf-d6e6-4d7f-9787-a386c216c50e.png" alt="DNS overview" class="image--center mx-auto" /></p>
<h2 id="heading-internal-working-of-dns">Internal working of DNS:</h2>
<p>When a user types a website URL (for example, www.chaicode.com) into the browser, the browser doesn't know the IP address of that website. So, it sends a request to the DNS (Domain Name System) to find the IP address. This process is called DNS Resolution.</p>
<p>Here’s how it works step-by-step:</p>
<ol>
<li><strong>Client Request</strong></li>
</ol>
<ul>
<li>The browser (client) sends a request to the DNS server asking for the IP address of <a target="_blank" href="http://www.chaicode.com">www.chaicode.com</a>.</li>
</ul>
<ol start="2">
<li><strong>Query to Root Server</strong></li>
</ol>
<ul>
<li>The DNS server forwards the request to a Root Server, which is the starting point in the DNS hierarchy.</li>
</ul>
<ol start="3">
<li><strong>Root Server Responds</strong></li>
</ol>
<ul>
<li>The Root Server doesn’t have the exact IP but knows where to find it. It replies with the IP address of the Top-Level Domain (TLD) server based on the domain extension — in this case, .com.</li>
</ul>
<ol start="4">
<li><strong>Query to TLD Server</strong></li>
</ol>
<ul>
<li>The DNS server then sends a request to the .com TLD server to find more information about chaicode.com.</li>
</ul>
<ol start="5">
<li><strong>TLD Server Responds</strong></li>
</ol>
<ul>
<li><p>The TLD server responds with the IP address of the Authoritative Name Server (ANS) for chaicode.com.</p>
</li>
<li><p>ANS is a crucial component of the Domain Name System (DNS). It is responsible for providing responses to queries about a specific domain, including the IP addresses of the domain's resources.</p>
</li>
</ul>
<blockquote>
<p>For example, if chaicode.com is hosted on GoDaddy, then GoDaddy’s name server is the ANS.</p>
</blockquote>
<ol start="6">
<li><strong>Query to Authoritative Name Server (ANS)</strong></li>
</ol>
<ul>
<li>Now the DNS server sends a final request to the ANS (e.g., GoDaddy) asking for the actual IP address of www.chaicode.com.</li>
</ul>
<ol start="7">
<li><p><strong>ANS Responds with IP</strong></p>
<ul>
<li>The Authoritative Name Server replies with the IP address of the requested website.</li>
</ul>
</li>
<li><p><strong>DNS Server Sends IP to Browser</strong></p>
</li>
</ol>
<ul>
<li>The DNS server sends the IP address back to the browser.</li>
</ul>
<ol start="9">
<li><strong>Browser Connects to Website</strong></li>
</ol>
<ul>
<li>With the IP address, the browser can now connect directly to the website’s server and load the web page.</li>
</ul>
<p>This entire process — from typing the URL to receiving the IP address — is called <strong>DNS Resolution</strong>, and it usually takes just milliseconds.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744535412090/fa6b3fb3-bb2c-4c80-b1d1-eb75099f5419.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Git & GitHub - Save, Track & Share Code]]></title><description><![CDATA[Introduction:
Have you ever worked on a project and wished you could go back to an earlier version? Or maybe you wanted to share your code with others easily? That’s where Git and GitHub come in!
In this blog, we’ll walk through the basics of what Gi...]]></description><link>https://blog.ms-dev.me/begin-git</link><guid isPermaLink="true">https://blog.ms-dev.me/begin-git</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Git]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[version control systems]]></category><category><![CDATA[webdev]]></category><category><![CDATA[cohort]]></category><dc:creator><![CDATA[MRUTYUNJAYA SAHOO]]></dc:creator><pubDate>Fri, 16 May 2025 18:40:22 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1746546239268/f2a40592-ed4b-4a48-9266-6b4bdf0634a4.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction:</h2>
<p>Have you ever worked on a project and wished you could go back to an earlier version? Or maybe you wanted to share your code with others easily? That’s where Git and GitHub come in!</p>
<p>In this blog, we’ll walk through the basics of what Git and GitHub are, how they help you save your work step-by-step, and how you can safely share your projects online and how to manage your code files history. Don’t worry — no fancy tech jargon here. Just clear, simple explanations to get you started.</p>
<h3 id="heading-what-is-a-version-control-system-vcs">📘 What is a Version Control System (VCS)?</h3>
<p>Imagine you're writing code on your own computer. Over time, you might add new features, fix bugs, or even accidentally break something that used to work. So how do you keep track of all these changes? How do you go back to the previous version if needed?</p>
<p>That’s where a <strong>Version Control System (VCS)</strong> comes in.</p>
<p>A <strong>VCS</strong> is like a smart record keeper for your code. It keeps track of every change you make — whether you're adding a new file, updating old ones, or deleting something. You can think of it like a time machine for your project.</p>
<blockquote>
<p>e.g. : Git, Subversion, Mercurial, Perforce</p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746558065385/f1ee5090-5b73-418e-9e87-af36796160d9.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-what-is-git"><strong>What is Git?</strong></h2>
<p>Git is a tool that helps you keep track of changes you make to your files — like saving different copies of your project as you work on it. It’s especially helpful when you're working with a team so that everyone can edit files without messing up each other’s work.</p>
<h3 id="heading-heres-how-it-usually-works-in-a-team">Here’s how it usually works in a team:</h3>
<ul>
<li><p>🔀 <strong>Start a Branch</strong><br />  You create your own copy (called a branch) from the main project, so you can work on it without affecting the original files (main branch).</p>
</li>
<li><p>✍️ <strong>Make Your Changes</strong><br />  You edit and update the files on your branch — it’s like having your own personal workspace.</p>
</li>
<li><p>🔁 <strong>Bring It All Together</strong><br />  Once you’re done, Git helps combine (or “merge”) your changes back into the main project (main branch), making sure nothing breaks or overlaps with your teammates’ updates.</p>
</li>
<li><p>🧠 <strong>Tracks Everything</strong><br />  Git keeps a full history of who changed what, so the whole team is always working on the latest copy and nothing gets lost.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746687535246/e81b5927-6adf-429c-9db5-a961c6a528af.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-install-git-quick-guide">🛠️ Install Git – Quick Guide</h3>
<h4 id="heading-windows">🪟 <strong>Windows</strong></h4>
<ol>
<li><p>Go to <a target="_blank" href="https://git-scm.com/downloads"><em>git-scm.com</em></a></p>
</li>
<li><p>Download the Git for Windows installer (<em>e.g.:</em> <strong><em>Git for Windows/x64 Setup</em>)</strong></p>
</li>
<li><p>Run the setup and follow the default options</p>
</li>
</ol>
<p>✅ To check:</p>
<ul>
<li><p>Open Command Prompt and run</p>
<pre><code class="lang-bash">  git --version
</code></pre>
</li>
</ul>
<h4 id="heading-macos">🍎 <strong>macOS</strong></h4>
<p>Option 1 (easiest):</p>
<ul>
<li><p>Open Terminal and type:</p>
<pre><code class="lang-bash">  git
</code></pre>
</li>
<li><p>It will prompt you to install Xcode Command Line Tools (includes Git).</p>
</li>
</ul>
<p>Option 2 (with Homebrew):</p>
<pre><code class="lang-bash">brew install git
</code></pre>
<p>✅ To check:</p>
<pre><code class="lang-bash">git --version
</code></pre>
<h4 id="heading-linux-ubuntudebian">🐧 <strong>Linux (Ubuntu/Debian)</strong></h4>
<ul>
<li><p>Open Terminal and run:</p>
<pre><code class="lang-bash">  sudo apt update  
  sudo apt install git
</code></pre>
</li>
</ul>
<p>✅ To check:</p>
<pre><code class="lang-bash">git --version
</code></pre>
<h3 id="heading-what-is-github">🌐 What is GitHub?</h3>
<p>GitHub is a web-based hosting service for Git repositories. GitHub is an online platform where you can <strong>store</strong>, <strong>share</strong>, and <strong>collaborate</strong> on code with others.</p>
<h3 id="heading-why-use-github">🔍 Why use GitHub?</h3>
<p>Storing your project in a <strong>repository</strong> on GitHub allows you to:</p>
<ul>
<li><p>📂 <strong>Keep your code safe</strong> in the cloud</p>
</li>
<li><p>👀 <strong>Share your work</strong> with others or showcase it publicly</p>
</li>
<li><p>🕒 <strong>Track changes</strong> made to your code over time</p>
</li>
<li><p>🧑‍💻 <strong>Collaborate easily</strong> with others without overwriting each other’s work</p>
</li>
<li><p>💬 <strong>Get feedback</strong> and suggestions from other developers</p>
</li>
</ul>
<p>📁 <strong>What is a Repository?</strong></p>
<p>A <strong>repository</strong> (or <strong>repo</strong>) is like a folder where your project lives. It stores all your code files, along with a history of the changes you make over time.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746776683148/a437d49a-807e-412e-8d89-06dbb97594d6.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-how-to-create-a-github-account">🧑‍💻 How to Create a GitHub Account</h3>
<ol>
<li><p><strong>Go to</strong> <a target="_blank" href="https://github.com">github.com</a></p>
</li>
<li><p>Click on <strong>“Sign up”</strong> (top right corner<a target="_blank" href="https://github.com">)</a></p>
</li>
<li><p>Enter your:</p>
<ul>
<li><p><strong>Username</strong></p>
</li>
<li><p><strong>Email address</strong></p>
</li>
<li><p><strong>Password</strong></p>
</li>
</ul>
</li>
<li><p>Follow the steps to verify your email and complete the setup.</p>
</li>
<li><p>You’re in! 🎉 Now you can create your first repository and start sharing code.</p>
</li>
</ol>
<h3 id="heading-your-config-settings">Your config settings:</h3>
<p>Before you start using Git, you need to tell it <strong>who you are</strong>.</p>
<p>After GitHub account is created then use the email and username.</p>
<h4 id="heading-step-1-open-your-terminal-or-command-prompt">🔧 Step 1: Open your terminal or command prompt</h4>
<p>Then run these two commands with your name and email:</p>
<pre><code class="lang-bash">git config --global user.name <span class="hljs-string">"Your Name"</span>
git config --global user.email <span class="hljs-string">"your@email.com"</span>
</code></pre>
<blockquote>
<p>Example:</p>
</blockquote>
<pre><code class="lang-bash">git config --global user.name <span class="hljs-string">"John Doe"</span>
git config --global user.email <span class="hljs-string">"johndoe@gmail.com"</span>
</code></pre>
<h4 id="heading-step-2-check-your-settings">✅ Step 2: Check your settings</h4>
<pre><code class="lang-bash">git config --list
</code></pre>
<p>If your name and email show up, you’re all set!</p>
<h2 id="heading-git-basic-commands">Git Basic Commands:</h2>
<p>To use Git, you can use these commands directly in the <strong>command line</strong>, or through tools like <strong>GitHub Desktop or</strong> right inside code editors like VS Code, Atom, Sublime Text, <strong>JetBrains IDEs</strong> like <strong>WebStorm</strong>, <strong>PyCharm</strong>, and <strong>IntelliJ IDEA</strong>, which provide a more visual experience.</p>
<blockquote>
<p>You don’t need to memorize every command—just get comfortable with the basics and you’ll build confidence as you go.</p>
</blockquote>
<h3 id="heading-1-start-a-local-git-projectfolder">📁 <strong>1. Start a Local Git Project(folder)</strong></h3>
<h3 id="heading-git-init"><code>git init</code></h3>
<p>✅ Use this when you're starting a new project and want Git to track it.</p>
<p>Use terminal to create folder or new directory or manually create folder on the file explorer.</p>
<pre><code class="lang-bash">mkdir your-project-name
<span class="hljs-built_in">cd</span> your-project-name
git init
<span class="hljs-comment">#example</span>
mkdir bigin-git
<span class="hljs-built_in">cd</span> bigin-git
git init
</code></pre>
<p>The above commands for creating in your terminal. But you can create directly in your code editor also.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746805802686/cb687192-f5de-446b-8266-088c968a2f1e.png" alt class="image--center mx-auto" /></p>
<p><strong><mark>.git folder:</mark></strong></p>
<p>When you run <code>git init</code>, Git creates a hidden folder called <code>.git</code> inside your project directory. This <code>.git</code> folder is like Git’s brain — it stores all the information Git needs to track changes, manage commits(snapshots), and handle commits, branches, and remotes.</p>
<blockquote>
<p><strong>Tip:</strong> Don't delete or edit this folder manually — it's essential for Git to work properly.</p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746805882396/cacf4239-69b8-498e-b47b-4177b30664e5.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-2-check-the-status-of-your-reporepository">📄 <strong>2. Check the status of your repo(repository):</strong></h3>
<h3 id="heading-git-status"><code>git status</code></h3>
<p>Shows the current state of your files (what's changed, what's staged).</p>
<p>✅ Run this often to see what Git is tracking.</p>
<pre><code class="lang-bash">git status
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746806313507/c9f68476-bde8-4818-a78b-cfa930d226e2.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-3-add-some-files">📄 <strong>3. Add Some Files</strong></h3>
<p>Create or copy your files (like <code>index.html</code>, <code>style.css</code>, etc.) inside the folder.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746804594415/53902194-34b9-46f2-8fab-a7e54d8d9fd0.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-4-track-and-stage">🔄 4. Track and Stage</h3>
<p><strong>Untrack File:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746806426259/c6df9110-38a2-4c10-bdc5-f502971f7ed7.png" alt class="image--center mx-auto" /></p>
<p>Then track the file use the below command;</p>
<h3 id="heading-git-add"><code>git add</code></h3>
<p>Adds changes to the "staging area" (preparing them to be saved).</p>
<p>📂 <em>Staging = preparing your files for a snapshot.</em></p>
<p>✅ Use this to tell Git which files you want to save.</p>
<pre><code class="lang-bash">git add filename.txt
<span class="hljs-comment"># or add all files</span>
git add .
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746806555223/7b330ddf-70d9-4fa4-af39-76d2757a26f5.png" alt class="image--center mx-auto" /></p>
<p><strong>Tracked</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746806589987/a18b6090-f123-48be-a1b5-eeae6bb14835.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-5-save-changes">💾 5. <strong>Save Changes</strong></h3>
<h3 id="heading-git-commit"><code>git commit</code></h3>
<p>Saves your staged changes with a message.</p>
<p>✅ Commits are like snapshots of your project at a point in time.</p>
<pre><code class="lang-bash">git commit -m <span class="hljs-string">"Added login feature"</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746806686072/ca1041dc-f0f6-4292-9a6d-973109692a93.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-6-view-commit-history-with-git-log">🕓 6. View Commit History with Git Log</h3>
<pre><code class="lang-bash"><span class="hljs-comment"># See the list of previous commits</span>
git <span class="hljs-built_in">log</span>
<span class="hljs-comment">#for viewing one line history of commits</span>
git <span class="hljs-built_in">log</span> --oneline
</code></pre>
<p>This shows you a timeline of changes — who made what change and when.<br />It helps track the project’s progress and debug if needed.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746807132940/6ccd026d-0ec2-4a0f-abf7-a0d20b4a04f3.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-7-create-a-remote-repository">☁️ <strong>7. Create a Remote Repository</strong></h3>
<p>Go to <a target="_blank" href="https://github.com/">GitHub.com</a>, log in, and click “New Repository.”</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746808148149/92b31159-fd73-40d5-96b0-588e06210113.png" alt="Click on dropdown" class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746808180525/d963064d-31bd-4b53-962b-488972550566.png" alt="Click on New repository" class="image--center mx-auto" /></p>
<p>Give it a name (like learning-git)</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746808251411/0082fcc9-2ad7-4c72-a865-d446c84e185c.png" alt="Give a repo name and click on Create repository" class="image--center mx-auto" /></p>
<h3 id="heading-8-connect-local-to-remote">🔗 <strong>8. Connect Local to Remote</strong></h3>
<pre><code class="lang-bash">git remote add origin https://github.com/your-username/my-project.git
<span class="hljs-comment">#example</span>
git remote add origin https://github.com/MrutyunjayaSahoo/learning-git.git
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746808643994/427bee06-ec8b-4678-8e7d-fe539cc2d0bd.png" alt class="image--center mx-auto" /></p>
<p>Now your local project is connected to the GitHub repo.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746808510337/f5d4c571-c61c-4ae2-9714-b25c37f770a0.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-9-push-code-to-github">🚀 <strong>9. Push Code to GitHub</strong></h3>
<p>✅ Use this to upload your work online or to a shared repo.</p>
<pre><code class="lang-bash">git push -u origin main
</code></pre>
<p>This sends your code to GitHub. <code>-u</code> sets the default remote so next time you can just use <code>git push</code>.</p>
<p>You’ll see this error because your local branch is named <code>master</code>, but you're trying to push to the <code>main</code> branch on GitHub. Since GitHub sets the default branch as <code>main</code>, you need to rename your local <code>master</code> branch to <code>main</code> to match it.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746809009631/78e7abe4-7611-4f04-906c-7c3e62295f1a.png" alt class="image--center mx-auto" /></p>
<p>Here’s a quick fix:</p>
<p>🔄 Rename Your Local Branch to <code>main</code></p>
<pre><code class="lang-bash"><span class="hljs-comment"># Rename the local branch</span>
git branch -m master main

<span class="hljs-comment"># Link your local main to the remote main</span>
git push -u origin main
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746809952790/bc1f680d-1398-4b21-b350-1690ba7d9402.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-10-make-more-changes-locally">🔄 <strong>10. Make More Changes Locally</strong></h3>
<pre><code class="lang-bash"><span class="hljs-comment"># Edit some files</span>
git add .
git commit -m <span class="hljs-string">"Updated homepage layout"</span>
git push
</code></pre>
<p>Now your updates are saved and shared again.</p>
<h3 id="heading-collaborating-with-a-team-using-git"><strong>🧑‍🤝‍🧑 Collaborating with a Team Using Git:</strong></h3>
<p>In a Git repository, multiple developers can’t commit to the same branch at the exact same time—it may cause conflicts. To avoid this, Git provides a <strong>branching system</strong>—each developer can create their own branch to make changes, commit, and push independently. Once their work is complete, it can be safely merged back into the main branch.</p>
<p><strong>🌱 Step 1: Fork the Repository on GitHub</strong></p>
<p>🔗 Go to the project repo on GitHub → click <strong>Fork</strong> (top right).<br />You’ll now have your own copy of the repo in your account.</p>
<blockquote>
<p><strong>GitHub itself doesn’t allow you to fork a repo into the same account where the original repo exists. So that use different account</strong></p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747073974462/4cd50b74-d605-4124-9a9d-6a2a0a289469.png" alt class="image--center mx-auto" /></p>
<ol>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747074287189/93df9b41-df76-4914-86d6-8d4cc0790a1e.png" alt class="image--center mx-auto" /></p>
<p> <strong>📥 Step 2: Clone the Forked Repo</strong></p>
<h3 id="heading-git-clone-forked-url"><code>git clone “forked-url”</code></h3>
<p> 📁 Cloning = downloading the full project and its history.</p>
<ul>
<li>Copy the forked repo URL</li>
</ul>
</li>
</ol>
<p>    <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747074373130/268591a4-ddc3-44fc-b59d-8953a186eb23.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-bash">git <span class="hljs-built_in">clone</span> https://github.com/yourusername/project-name.git
<span class="hljs-built_in">cd</span> project-name
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747074744870/5899e7aa-ba39-4d78-832b-f21b9acb9b3d.png" alt class="image--center mx-auto" /></p>
<p><strong>🌿 Step 3: Create a Branch</strong></p>
<p>All branches are created from the main branch. The main branch is present in the production server.</p>
<p>If you want to contribute to a project, it's a good practice to create a branch with a name like:<br /><code>yourusername/feature-name</code> or <code>yourusername/repo-name</code></p>
<p>✅ This helps your team easily recognize:</p>
<ul>
<li><p>Who created the branch</p>
</li>
<li><p>What the branch is for</p>
</li>
</ul>
<p>🔍 Example:</p>
<p>for feature name<br /><code>Mrutyunjaya-Sahoo/added-login-form</code></p>
<p>for repo name</p>
<p><code>Mrutyunjaya-Sahoo/webdev-cohort-opensource</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747074835237/79f56ffd-d1ad-4806-a297-a6da9cbac624.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-git-branch"><code>git branch &lt;branchname&gt;</code></h3>
<p>🌿 Branches let you work safely without affecting the main code.</p>
<pre><code class="lang-bash"><span class="hljs-comment">#To see the list or current branch</span>
git branch
<span class="hljs-comment">#Create a branch</span>
git branch &lt;yourbranchname&gt;
<span class="hljs-comment">#example</span>
git branch MrutyunjayaSahoo/Login-Form
</code></pre>
<h4 id="heading-step-4-switch-to-created-branch">🔀<strong>Step 4: Switch to created branch</strong></h4>
<h3 id="heading-git-checkout"><code>git checkout &lt;branchname&gt;</code></h3>
<p>Switches between branches or files.</p>
<p>✅ Move to a different branch or restore a previous version of a file.</p>
<pre><code class="lang-bash">git checkout &lt;branchname&gt;
<span class="hljs-comment">#example</span>
git checkout MrutyunjayaSahoo/Login-Form
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747074935344/9a4cb607-bacc-49cc-b4d8-d157776f5756.png" alt class="image--center mx-auto" /></p>
<p><strong>📄Step 5: Create a file</strong></p>
<p>Once you've created your branch when contributing to a Git project.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747074537527/3b3e1f3f-1246-4501-a793-3be60ac621d0.png" alt class="image--center mx-auto" /></p>
<p><strong>🛠️ Step 6: Make Changes Locally</strong></p>
<p>Edit code, save your files.</p>
<p><strong>✅ Step 7: Add &amp; Commit</strong></p>
<p>📝 Snapshot your work before sharing it.</p>
<pre><code class="lang-bash">git add .
git commit -m <span class="hljs-string">"Added Login Form"</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747074985313/f42060c4-9dee-4a93-935e-9f33b6a7affe.png" alt class="image--center mx-auto" /></p>
<p><strong>📤 Step 8: Push to Your Fork</strong></p>
<pre><code class="lang-bash">git push
</code></pre>
<ul>
<li>You're seeing this error because Git doesn't yet know <strong>where</strong> to push your newly created branch. This happens when you create a new branch locally but haven't told Git which remote branch to track for pushing.</li>
</ul>
<p>❌ Error:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747075016259/2784d573-4c56-46b7-be13-4f5746b98142.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-solution">✅ Solution:</h3>
<p>You need to tell Git to both push and <strong>set the remote branch</strong> for the first time like this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747075068361/43ea8d67-1a8d-49b2-b1a6-d7a61cec9fa4.png" alt class="image--center mx-auto" /></p>
<p>📦 <em>Send your changes to your forked repo on GitHub.</em></p>
<p>🔁 <strong>Step 8: Open a Pull Request (PR)</strong></p>
<ul>
<li><p>Go to your forked repo on GitHub</p>
</li>
<li><p>Click <strong>Compare &amp; Pull Request</strong></p>
</li>
<li><p>Write a message and click <strong>Create Pull Request</strong></p>
</li>
</ul>
<p>💬 <em>A pull request tells the original team: “Here are my changes, please review and merge them.”</em></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747075179343/28fdba5a-4f49-485c-ab4b-b421b8449f92.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747075257260/bf71e19f-342b-4824-86be-92edf13cc9ba.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-merge"><strong>🔄</strong> Merge:</h3>
<h4 id="heading-use-git-merge-after-your-branch-is-reviewed-and-approved"><strong>Use</strong> <code>git merge</code> <strong>after your branch is reviewed and approved:</strong></h4>
<blockquote>
<p>Make sure you are in a remote repo to see the branches and merged commits.</p>
</blockquote>
<p>In a team workflow, all new branches are created from the main branch. The main branch typically represents the live or production version of the project.</p>
<p>You <strong>can’t merge directly to</strong> <code>main</code> Instead:</p>
<ul>
<li><p>Create your own branch.</p>
</li>
<li><p>Push changes and open a <strong>Pull Request</strong>.</p>
</li>
<li><p>Once reviewed and approved by the team, it gets <strong>merged</strong> into <code>main</code>.</p>
</li>
<li><p>After merge, changes are automatically <strong>deployed to production</strong>.</p>
</li>
</ul>
<blockquote>
<p>In every merging, always switch to the <code>main</code> branch then you can merge your branch to <code>main</code> branch.</p>
</blockquote>
<p>This keeps the main branch clean and safe! 🚀</p>
<pre><code class="lang-bash">git branch &lt;branchname&gt;
git checkout &lt;branchname&gt;
git branch
<span class="hljs-comment">#example</span>
git branch frontend
git checkout frontend
git branch
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747381022551/a7a1d10e-18e5-4db2-8be6-774b47e15544.png" alt class="image--center mx-auto" /></p>
<p><strong>Now create a folder or file:</strong></p>
<p>I have created a folder named “frontend” because I want to add more features like about us, contact us to the same branch i.e. frontend.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747381566316/4832e831-5627-4eef-ae73-90b28c4570ab.png" alt class="image--center mx-auto" /></p>
<p><strong>➕ Add and Commit Your Work</strong></p>
<p>After adding your files:</p>
<pre><code class="lang-bash">git add .                <span class="hljs-comment"># Stage all your changes</span>
git commit -m <span class="hljs-string">"Added about and contact us pages"</span>
</code></pre>
<p>This saves your changes <em>only in the</em> <code>frontend</code> branch.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747382222455/2354ab56-588f-4b41-8d16-7522a5a165d4.png" alt class="image--center mx-auto" /></p>
<p><strong>🔄 Go Back to Main Branch</strong></p>
<p>Now, if you switch back to the <code>main</code> branch:</p>
<pre><code class="lang-bash">git checkout main
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747382462494/8d71f27a-daed-42db-b8b3-83f780fa7c7e.png" alt class="image--center mx-auto" /></p>
<p>You’ll notice the <code>frontend</code> folder and files are <strong>gone</strong>! Don’t worry — they’re still safe in the <code>frontend</code> branch.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747382282529/b81291ef-0a57-4263-9fb8-ffbce1a7b802.png" alt class="image--center mx-auto" /></p>
<p><strong>🔗 Merge Your Work Into Main</strong></p>
<p>Once your work in the <code>frontend</code> branch is complete and ready:</p>
<pre><code class="lang-bash">git merge frontend
</code></pre>
<p>Now, all the files and folders you added in the <code>frontend</code> branch will be <strong>merged into the main branch</strong> and become part of your main project. ✅</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747382500366/f130d991-1073-4b0a-956d-df69f31a0a50.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747382519831/f11e6182-ac0d-4c82-8f9c-364feecad46d.png" alt class="image--center mx-auto" /></p>
<p><strong>As you can see there are two branches and commits of new branch;</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747384391277/bdceb577-575f-4487-8be5-90ef9a930f43.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747384450083/9a2f2e5f-c0af-483c-b83b-a2d92f924115.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-merge-workflow">Merge Workflow:</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747404336223/e899d3bb-f631-407b-b37b-c225bc644059.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-squash-merge">🧹<strong>Squash Merge:</strong></h3>
<h3 id="heading-git-merge-squash-clean-and-combine-your-commits"><code>git merge --squash</code> — Clean and Combine Your Commits</h3>
<p>When you've made <strong>lots of small commits</strong> in your feature branch but want to <strong>combine them into one single commit</strong> before merging to the main branch, you can use:</p>
<pre><code class="lang-bash">git merge --squash &lt;branch-name&gt;
</code></pre>
<p><strong>✅ Why Use</strong> <code>--squash</code><strong>?</strong></p>
<ul>
<li><p>Keeps your main branch <strong>clean and readable</strong>.</p>
</li>
<li><p>Combines all changes from a branch into <strong>one neat commit</strong>.</p>
</li>
<li><p>Helpful when your commit history is messy (like 10 commits just fixing typos 😅).</p>
</li>
</ul>
<hr />
<p><strong>🔄 Example Workflow</strong></p>
<p>Let’s say you are on the <code>main</code> branch and want to merge the <code>frontend</code> branch cleanly:</p>
<pre><code class="lang-bash">git checkout main
git merge --squash frontend
git commit -m <span class="hljs-string">"Added frontend features (about, contact pages)"</span>
</code></pre>
<ul>
<li><p>This <strong>collects all the changes</strong> from the <code>frontend</code> branch,</p>
</li>
<li><p>And lets you <strong>create one final commit</strong> manually.</p>
</li>
</ul>
<blockquote>
<p>Note: The <code>frontend</code> branch history won't come with the merge — just the changes.</p>
</blockquote>
<p><strong>Squash Merge Workflow:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747405300423/90e45eaf-fb54-45aa-b2c8-6b883b4cf3f5.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-what-is-git-rebase">🔁 What is Git Rebase?</h3>
<p><code>git rebase</code> is used to <strong>rewrite the commit history</strong> in a cleaner, linear way.</p>
<p>When multiple developers are working on the same branch, some may finish their features earlier while others take more time. If everyone merges directly into the main branch, the commit history becomes messy and hard to follow.</p>
<p>Instead of merging, you can use:</p>
<pre><code class="lang-bash">git rebase main
</code></pre>
<p>This moves your branch to the latest point of the main branch, replaying your commits <strong>one by one</strong> on top of it — keeping the history clean and linear.</p>
<hr />
<h3 id="heading-example-scenario">💡 Example Scenario:</h3>
<ul>
<li><p>Developer A creates <code>feature-a</code> and finishes work quickly.</p>
</li>
<li><p>Developer B creates <code>feature-b</code> but takes longer to complete it.</p>
</li>
<li><p>Meanwhile, <code>feature-a</code> is already merged into <code>main</code>.</p>
</li>
</ul>
<p>Now Developer B’s history is <strong>outdated</strong> compared to <code>main</code>.</p>
<p>So before merging, Developer B runs:</p>
<pre><code class="lang-bash">git checkout feature-b
git rebase main
</code></pre>
<p>This takes B’s commits and <strong>reapplies them on top of the updated main branch</strong>, making it look like they were written just now — as if everything happened in order.</p>
<hr />
<h3 id="heading-benefits-of-rebase">✅ Benefits of Rebase:</h3>
<ul>
<li><p>Clean, linear commit history.</p>
</li>
<li><p>Easier to read project timeline.</p>
</li>
<li><p>Avoids unnecessary merge commits.</p>
</li>
</ul>
<p><strong>Rebase Workflow:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747419695014/46bfbdaa-91a5-4a24-9354-aac0a56ea46c.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-essential-git-commands-cheat-sheet"><strong>🛠️ Essential Git Commands Cheat Sheet:</strong></h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Category</strong></td><td><strong>Command</strong></td><td><strong>Description</strong></td></tr>
</thead>
<tbody>
<tr>
<td>🔧 <strong>Setup</strong></td><td><code>git config --global</code> <a target="_blank" href="http://user.name"><code>user.name</code></a> <code>"Your Name"</code></td><td>Set your name</td></tr>
<tr>
<td></td><td><code>git config --global</code> <a target="_blank" href="http://user.email"><code>user.email</code></a> <code>"</code><a target="_blank" href="mailto:email@example.com"><code>email@example.com</code></a><code>"</code></td><td>Set your email</td></tr>
<tr>
<td></td><td><code>git config --global core.editor code</code></td><td>Set VS Code as default editor</td></tr>
<tr>
<td></td><td><code>git config --list</code></td><td>List all Git configs</td></tr>
</tbody>
</table>
</div><hr />
<div class="hn-table">
<table>
<thead>
<tr>
<td>📁 <strong>Repository Basics</strong></td><td><strong>Command</strong></td><td><strong>Description</strong></td></tr>
</thead>
<tbody>
<tr>
<td>Init</td><td><code>git init</code></td><td>Initialize new Git repository</td></tr>
<tr>
<td>Clone</td><td><code>git clone &lt;url&gt;</code></td><td>Clone a remote repository</td></tr>
<tr>
<td>Status</td><td><code>git status</code></td><td>Check status of changes</td></tr>
<tr>
<td>Log</td><td><code>git log</code></td><td>Show commit history</td></tr>
<tr>
<td>Short Log</td><td><code>git log --oneline --graph</code></td><td>View condensed history graph</td></tr>
</tbody>
</table>
</div><hr />
<div class="hn-table">
<table>
<thead>
<tr>
<td>✍️ Working with Commits</td><td><strong>Command</strong></td><td><strong>Description</strong></td></tr>
</thead>
<tbody>
<tr>
<td>Add</td><td><code>git add &lt;file&gt;</code></td><td>Stage a file</td></tr>
<tr>
<td>Add All</td><td><code>git add .</code> or <code>git add -A</code></td><td>Stage all files</td></tr>
<tr>
<td>Commit</td><td><code>git commit -m "message"</code></td><td>Commit changes</td></tr>
<tr>
<td>Amend</td><td><code>git commit --amend</code></td><td>Edit last commit</td></tr>
<tr>
<td>Restore File</td><td><code>git restore &lt;file&gt;</code></td><td>Discard changes in file</td></tr>
<tr>
<td>Reset File</td><td><code>git reset &lt;file&gt;</code></td><td>Unstage a staged file</td></tr>
</tbody>
</table>
</div><hr />
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>🌿 Branches</strong></td><td><strong>Command</strong></td><td><strong>Description</strong></td></tr>
</thead>
<tbody>
<tr>
<td>List Branches</td><td><code>git branch</code></td><td>List local branches</td></tr>
<tr>
<td>Create Branch</td><td><code>git branch &lt;branchname&gt;</code></td><td>Create new branch</td></tr>
<tr>
<td>Switch Branch</td><td><code>git checkout &lt;branchname&gt;</code></td><td>Switch to branch</td></tr>
<tr>
<td>Rename Branch</td><td><code>git branch -m &lt;newname&gt;</code></td><td>Rename current branch</td></tr>
<tr>
<td>Delete Branch</td><td><code>git branch -d &lt;branchname&gt;</code></td><td>Delete branch</td></tr>
<tr>
<td>Create &amp; Switch</td><td><code>git checkout -b &lt;branchname&gt;</code></td><td>Create and switch to new branch</td></tr>
</tbody>
</table>
</div><hr />
<div class="hn-table">
<table>
<thead>
<tr>
<td>🔀 <strong>Merging &amp; Rebasing</strong></td><td><strong>Command</strong></td><td><strong>Description</strong></td></tr>
</thead>
<tbody>
<tr>
<td>Merge</td><td><code>git merge &lt;branch&gt;</code></td><td>Merge branch into current</td></tr>
<tr>
<td>Squash Merge</td><td><code>git merge --squash &lt;branch&gt;</code></td><td>Merge with squashing commits</td></tr>
<tr>
<td>Rebase</td><td><code>git rebase &lt;branch&gt;</code></td><td>Rebase onto another branch</td></tr>
<tr>
<td>Abort Rebase</td><td><code>git rebase --abort</code></td><td>Cancel a rebase</td></tr>
<tr>
<td>Continue Rebase</td><td><code>git rebase --continue</code></td><td>Continue after conflict resolution</td></tr>
</tbody>
</table>
</div><hr />
<div class="hn-table">
<table>
<thead>
<tr>
<td>🔁 <strong>Undo &amp; History</strong></td><td><strong>Command</strong></td><td><strong>Description</strong></td></tr>
</thead>
<tbody>
<tr>
<td>Revert</td><td><code>git revert &lt;commit&gt;</code></td><td>Undo a commit (safe)</td></tr>
<tr>
<td>Reset Soft</td><td><code>git reset --soft &lt;commit&gt;</code></td><td>Move HEAD but keep changes staged</td></tr>
<tr>
<td>Reset Mixed</td><td><code>git reset --mixed &lt;commit&gt;</code></td><td>Unstage and keep changes</td></tr>
<tr>
<td>Reset Hard</td><td><code>git reset --hard &lt;commit&gt;</code></td><td>Discard all changes</td></tr>
</tbody>
</table>
</div><hr />
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>📤 Remote Operations</strong></td><td><strong>Command</strong></td><td><strong>Description</strong></td></tr>
</thead>
<tbody>
<tr>
<td>Add Remote</td><td><code>git remote add origin &lt;url&gt;</code></td><td>Link local repo to remote</td></tr>
<tr>
<td>View Remotes</td><td><code>git remote -v</code></td><td>List remote URLs</td></tr>
<tr>
<td>Push</td><td><code>git push origin &lt;branch&gt;</code></td><td>Push branch to remote</td></tr>
<tr>
<td>Pull</td><td><code>git pull origin &lt;branch&gt;</code></td><td>Pull changes from remote</td></tr>
<tr>
<td>Fetch</td><td><code>git fetch</code></td><td>Get latest commits without merging</td></tr>
</tbody>
</table>
</div><hr />
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>💡 Stash &amp; Tagging</strong></td><td><strong>Command</strong></td><td><strong>Description</strong></td></tr>
</thead>
<tbody>
<tr>
<td>Stash</td><td><code>git stash</code></td><td>Save uncommitted changes</td></tr>
<tr>
<td>Stash List</td><td><code>git stash list</code></td><td>Show stashes</td></tr>
<tr>
<td>Stash Apply</td><td><code>git stash apply</code></td><td>Reapply last stash</td></tr>
<tr>
<td>Tag</td><td><code>git tag &lt;tagname&gt;</code></td><td>Create a tag</td></tr>
<tr>
<td>Tag Push</td><td><code>git push origin &lt;tagname&gt;</code></td><td>Push a tag to remote</td></tr>
</tbody>
</table>
</div><hr />
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>📋 Misc &amp; Helpers</strong></td><td><strong>Command</strong></td><td><strong>Description</strong></td></tr>
</thead>
<tbody>
<tr>
<td>Show Commit</td><td><code>git show &lt;commit&gt;</code></td><td>Show specific commit details</td></tr>
<tr>
<td>Diff</td><td><code>git diff</code></td><td>View unstaged changes</td></tr>
<tr>
<td>Diff Staged</td><td><code>git diff --staged</code></td><td>View staged changes</td></tr>
<tr>
<td>Clean Untracked Files</td><td><code>git clean -f</code></td><td>Remove untracked files</td></tr>
<tr>
<td>Aliases</td><td><code>git config --global alias.&lt;short&gt;=&lt;command&gt;</code></td><td>Create Git aliases</td></tr>
</tbody>
</table>
</div><h3 id="heading-git-shortcuts-cheat-sheet">⚡ Git Shortcuts Cheat Sheet:</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Full Command</strong></td><td><strong>Shortcut / Combined Version</strong></td><td><strong>Description</strong></td></tr>
</thead>
<tbody>
<tr>
<td><code>git add .</code> + <code>git commit -m "msg"</code></td><td><code>git commit -am "msg"</code></td><td>Add all tracked changes &amp; commit in one step</td></tr>
<tr>
<td><code>git branch &lt;branchname&gt;</code> + <code>git checkout &lt;branchname&gt;</code></td><td><code>git checkout -b &lt;branch&gt;</code></td><td>Create and switch to new branch (no shorter form)</td></tr>
<tr>
<td><code>git status</code></td><td><code>gst</code> (with alias: <code>git config --global alias.gst status</code>)</td><td>Show status quickly</td></tr>
<tr>
<td><code>git log --oneline --graph</code></td><td><code>git lg</code> (alias)</td><td>Compact, graphical commit log</td></tr>
<tr>
<td><code>git remote -v</code></td><td><code>grv</code> (alias)</td><td>List all remotes verbosely</td></tr>
<tr>
<td><code>git branch</code></td><td><code>gb</code> (alias)</td><td>List all branches</td></tr>
<tr>
<td><code>git checkout &lt;branch&gt;</code></td><td><code>gco &lt;branch&gt;</code> (alias)</td><td>Switch to a branch</td></tr>
<tr>
<td><code>git commit --amend</code></td><td><code>gca</code> (alias)</td><td>Amend the last commit</td></tr>
<tr>
<td><code>git reset --hard</code></td><td><code>grh</code> (alias)</td><td>Reset completely to previous commit</td></tr>
<tr>
<td><code>git fetch --all --prune</code></td><td><code>gfa</code> (alias)</td><td>Fetch all remotes and clean up deleted branches</td></tr>
<tr>
<td><code>git log --oneline</code></td><td><code>glog</code> (alias)</td><td>Compact commit history</td></tr>
<tr>
<td><code>git pull --rebase</code></td><td><code>gpr</code> (alias)</td><td>Pull with rebase instead of merge</td></tr>
<tr>
<td><code>git stash save "msg"</code></td><td><code>gss "msg"</code> (alias)</td><td>Stash with custom message</td></tr>
<tr>
<td><code>git stash apply stash@{n}</code></td><td><code>gsa n</code> (alias with function)</td><td>Apply specific stash</td></tr>
<tr>
<td><code>git diff</code></td><td><code>gd</code> (alias)</td><td>Show working directory changes</td></tr>
<tr>
<td><code>git diff --staged</code></td><td><code>gds</code> (alias)</td><td>Show staged changes only</td></tr>
<tr>
<td><code>git log --stat</code></td><td><code>gls</code> (alias)</td><td>Commit log with diff stats</td></tr>
<tr>
<td><code>git rebase -i HEAD~n</code></td><td>—</td><td>Interactive rebase for last <code>n</code> commits</td></tr>
</tbody>
</table>
</div><hr />
<h3 id="heading-how-to-set-up-git-aliases">✅ How to Set Up Git Aliases:</h3>
<p>Use this format to create your own:</p>
<pre><code class="lang-bash">git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.br branch
git config --global alias.lg <span class="hljs-string">"log --oneline --graph --all"</span>
</code></pre>
<h2 id="heading-final-thoughts">🎯 Final Thoughts:</h2>
<p>Git is more than just a tool — it's your coding time machine, your collaboration buddy, and your safety net when things go wrong. Whether you're building solo projects or working in a fast-paced team, mastering Git helps you <strong>stay organized</strong>, <strong>work efficiently</strong>, and <strong>collaborate confidently</strong>.</p>
<p>From branching and merging to pushing and pulling — every command you’ve learned adds power to your workflow. So keep experimenting, keep committing, and let Git be the silent force behind your development journey.</p>
<p>🚀 <strong>Code smart. Collaborate better. Git ahead.</strong></p>
]]></content:encoded></item></channel></rss>