<?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[Git for Beginners: Essential Commands]]></title><description><![CDATA[Git for Beginners: Essential Commands]]></description><link>https://prashant-dev.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 18 Jun 2026 08:54:50 GMT</lastBuildDate><atom:link href="https://prashant-dev.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Git for Beginners: Basics and Essential Commands]]></title><description><![CDATA[Coding without GIT is driving without a seatbelt. You might survive, but one wrong move and it’s game over.
Master Your Code History
If you have a project folder that looks like this:

project_final.code

project_final_v2.code

project_REALLY_FINAL_T...]]></description><link>https://prashant-dev.hashnode.dev/git-for-beginners-basics-and-essential-commands</link><guid isPermaLink="true">https://prashant-dev.hashnode.dev/git-for-beginners-basics-and-essential-commands</guid><category><![CDATA[Git]]></category><dc:creator><![CDATA[Prashant Priyadarshi]]></dc:creator><pubDate>Wed, 28 Jan 2026 18:41:44 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769635531283/875d4939-9ced-4659-b20d-97d2c0570a55.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Coding without GIT is driving without a seatbelt. You <em>might</em> survive, but one wrong move and it’s game over.</p>
<h2 id="heading-master-your-code-history"><strong>Master Your Code History</strong></h2>
<p>If you have a project folder that looks like this:</p>
<ul>
<li><p>project_final.code</p>
</li>
<li><p>project_final_v2.code</p>
</li>
<li><p>project_REALLY_FINAL_THIS_TIME.code</p>
</li>
<li><p>project_FOR_GODS_SAKE_WORK.code</p>
</li>
</ul>
<p>We’ve all been there. We make a change, code breaks, panic, and we wish we had a magical "Undo" button. Well, in the coding world, that magical button exists. It’s called <strong>Git</strong>.</p>
<h2 id="heading-what-is-git"><strong>What is Git?</strong></h2>
<p>Imagine you are playing a difficult video game. Before fighting a major boss, what do you do? <strong>You save the game.</strong></p>
<p>Why? Because if the boss defeats you, you don't want to start the entire game from level one. You want to reload right before the fight and try again. <strong>Git is the "Save Game" feature for your coding projects.</strong></p>
<p>In technical terms: Git is a <strong>Distributed Version Control System</strong>. It manages different versions of your project over time. It takes <strong>snapshots</strong> of your files so you can travel back in time to when things worked perfectly.</p>
<p>In simple words: Git helps you <strong>track changes in your code</strong>, go back in time if something breaks, and work with others <strong>without messing things up</strong>.</p>
<p>Think of Git like this:</p>
<ul>
<li><p>You’re writing code every day</p>
</li>
<li><p>You save versions of your work</p>
</li>
<li><p>Git keeps a <strong>history of every change</strong></p>
</li>
<li><p>You can undo mistakes without crying</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769623359076/b5b587e1-6c4a-4485-9c73-f7a42af8fb85.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-git-basics-amp-core-terminologies"><strong>Git Basics &amp; Core Terminologies</strong></h2>
<p>Let’s decode the scary words.</p>
<p><strong>1. Repository (Repo)</strong></p>
<p>A <strong>repository</strong> is just a folder where Git tracks your code and its history.</p>
<p>It contains:</p>
<ul>
<li><p>Your files</p>
</li>
<li><p>Git metadata (hidden .git folder)</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769623615097/02c59902-7ebb-4fb1-9b33-536a7e5bb508.png" alt class="image--center mx-auto" /></p>
<p><strong>2. Commit</strong></p>
<p>A <strong>commit</strong> is a saved snapshot of your code at a point in time.</p>
<p>Each commit has:</p>
<ul>
<li><p>Unique ID</p>
</li>
<li><p>Message</p>
</li>
<li><p>Timestamp</p>
</li>
</ul>
<p>📌 <strong>Rule:</strong> Commit small, commit often.</p>
<p><strong>3. Branch</strong></p>
<p>A <strong>branch</strong> is a separate line of development.</p>
<p>Default branch = main or master</p>
<p>Use branches to:</p>
<ul>
<li><p>Try new features</p>
</li>
<li><p>Fix bugs</p>
</li>
<li><p>Avoid breaking main code</p>
</li>
</ul>
<p>💡 Branch = “Let me experiment without risk”</p>
<p><strong>4. HEAD</strong></p>
<p><strong>HEAD</strong> is where you are right now in Git history.</p>
<p>Simple:</p>
<ul>
<li><p>HEAD points to the <strong>current commit</strong></p>
</li>
<li><p>Move HEAD → change versions</p>
</li>
</ul>
<p><strong>Why do we need it?</strong></p>
<ol>
<li><p><strong>The Time Machine:</strong> You deleted a crucial function yesterday and realized you need it today? Git lets you get it back in seconds.</p>
</li>
<li><p><strong>Working Together without Killing Each Other:</strong> Imagine two people editing the same file at the same time on Google Drive/Dropbox. It’s chaotic. Git manages this beautifully, allowing whole teams to work on the same project without overwriting each other's code.</p>
</li>
<li><p><strong>Experiment Fearlessly:</strong> Want to try a crazy new feature that might break everything? Git lets you create a parallel universe (called a "branch") to test things out. If it fails, you delete the universe. If it works, you merge it into the main project.</p>
</li>
</ol>
<h2 id="heading-common-git-commands"><strong>Common Git Commands</strong></h2>
<p><strong>1. git init</strong></p>
<p>This command turns a regular folder into a Git repository. It creates that hidden .git vault.</p>
<p>What it does:</p>
<ul>
<li><p>Creates .git folder</p>
</li>
<li><p>Git starts tracking this project</p>
</li>
</ul>
<p><strong>2. git status</strong></p>
<p>This is the command we use most often. It tells us the state of our Working Directory and Staging Area. It answers: <em>"What have I changed? What is ready to be saved?"</em></p>
<p>Tells you:</p>
<ul>
<li><p>Modified files</p>
</li>
<li><p>Staged files</p>
</li>
<li><p>Untracked files</p>
</li>
</ul>
<p><strong>3. git add</strong></p>
<p>This moves changes from your Working Directory to the Staging Area.</p>
<pre><code class="lang-javascript">git add file.js.  <span class="hljs-comment">// adds specific file</span>
git add .     <span class="hljs-comment">// Add everything:</span>
</code></pre>
<p>📌 This does NOT save yet. It just prepares.</p>
<p><strong>4. git commit</strong></p>
<p>This takes the snapshot of whatever is inside the Staging Area and saves it to the Vault.</p>
<pre><code class="lang-javascript">git commit -m <span class="hljs-string">"Add login page UI"</span>
</code></pre>
<p>Rules: Always write a meaningful message! Don't write "fixed stuff". Write "Fixed the navigation bar alignment issue". Future you will thank present you</p>
<p><strong>5. git log</strong></p>
<p>This shows a list of all past commits, who made them, when, and their messages.</p>
<p>You’ll see:</p>
<ul>
<li><p>Commit ID</p>
</li>
<li><p>Author</p>
</li>
<li><p>Date</p>
</li>
<li><p>Message</p>
</li>
</ul>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Command</strong></td><td><strong>Direction</strong></td><td><strong>What it actually does</strong></td></tr>
</thead>
<tbody>
<tr>
<td><strong>git add</strong></td><td>Working Dir → Staging</td><td>Takes your "messy" changes and prepares them for a snapshot.</td></tr>
<tr>
<td><strong>git commit</strong></td><td>Staging → Repository</td><td>Takes everything in the "loading dock" and saves it permanently with a message.</td></tr>
<tr>
<td><strong>git checkout</strong></td><td>Repository → Working Dir</td><td>This is the "Time Travel" button. It pulls an old version out of the vault and puts it back on your factory floor so you can see it again.</td></tr>
</tbody>
</table>
</div><h2 id="heading-a-basic-developer-workflow-building-a-chai-recipe-site"><strong>A Basic Developer Workflow: Building a "Chai Recipe" Site</strong></h2>
<p>Let’s walk through a real scenario from absolute scratch.</p>
<p><strong>Step 1: Setup</strong> Create a folder for our project and enter it.</p>
<pre><code class="lang-javascript">mkdir chai_project

cd chai_project
</code></pre>
<p>Now, tell Git to start watching this folder.</p>
<p>Bash</p>
<pre><code class="lang-javascript">git init
</code></pre>
<p><em>(Output: Initialized empty Git repository in /chai_project/.git/)</em></p>
<p><strong>Step 2: Create content (Working Directory)</strong>.</p>
<p>Create a file named recipe.txt and add some text to it: "Ingredients: Water, Tea Leaves, Sugar, Milk."</p>
<p><strong>Step 3: Check what's going on</strong></p>
<pre><code class="lang-javascript">git status
</code></pre>
<p><em>Git will tell you in red text that recipe.txt is "Untracked". It sees it in the Working Directory but it's not in the Staging Area yet.</em></p>
<p><strong>Step 4: Stage the file (Move to Staging Area)</strong> We like this file. Let's prepare it for saving.</p>
<pre><code class="lang-javascript">git add recipe.txt
</code></pre>
<p><strong><em>If you run git status now, the text will turn green. It's ready to be committed.</em></strong></p>
<p><strong>Step 5: Commit the file (Move to Vault)</strong> Take the snapshot.</p>
<pre><code class="lang-javascript">git commit -m <span class="hljs-string">"Initial commit: Added base ingredients list"</span>
</code></pre>
<p><em>(Output: [main (root-commit) ...] Initial commit: Added base ingredients list)</em></p>
<p><strong>Step 6: Make changes and repeat</strong> Let's update the file. Add "Ginger and Cardamom" to your recipe.txt.</p>
<p>Run git status. Git sees you modified the file. Run git add . to stage the change. Run git commit -m "Added spices for better taste" to save the new snapshot.</p>
<p><strong>Step 7: View History</strong> See what we have done so far.</p>
<pre><code class="lang-javascript">git log
</code></pre>
<p><em>You will see two entries. Your initial commit, and your spicy commit with timestamps.</em></p>
]]></content:encoded></item></channel></rss>