<?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 Basics and Essential Commands]]></title><description><![CDATA[Git Basics and Essential Commands]]></description><link>https://git-for-beginners-basics-and-essential-commands.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 17 Jun 2026 23:29:45 GMT</lastBuildDate><atom:link href="https://git-for-beginners-basics-and-essential-commands.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Mastering the Git Basics With Essential Commands]]></title><description><![CDATA[Ever found yourself in a coding project, making changes, only to realize you messed something up and wish you could go back to a previous version? Or perhaps you're collaborating with others, and keeping track of who changed what, and when, becomes a...]]></description><link>https://git-for-beginners-basics-and-essential-commands.hashnode.dev/mastering-the-git-basics-with-essential-commands</link><guid isPermaLink="true">https://git-for-beginners-basics-and-essential-commands.hashnode.dev/mastering-the-git-basics-with-essential-commands</guid><category><![CDATA[Basics and Essential Commands of git]]></category><category><![CDATA[Why Git is Used]]></category><category><![CDATA[Git Basics and Core Terminologies]]></category><category><![CDATA[Common Git Commands]]></category><category><![CDATA[gitforbeginners]]></category><category><![CDATA[What is git]]></category><dc:creator><![CDATA[Anil Kambar]]></dc:creator><pubDate>Sat, 10 Jan 2026 12:01:04 GMT</pubDate><content:encoded><![CDATA[<p>Ever found yourself in a coding project, making changes, only to realize you messed something up and wish you could go back to a previous version? Or perhaps you're collaborating with others, and keeping track of who changed what, and when, becomes a tangled mess? If so, then Git is about to become your new best friend!</p>
<p>In the world of software development, Git is an indispensable tool. It's not just for professional developers; anyone working on projects that involve multiple iterations or collaboration can benefit immensely from understanding its fundamentals.</p>
<h2 id="heading-what-is-git"><strong>What is Git?</strong></h2>
<p>Git is a <strong>Version Control System,</strong> it helps you track changes in your code over time.</p>
<p><strong>Imagine:</strong> When you write code today and modify it tomorrow, there’s always a chance that something might break. In such situations, you may want to return to the last working version of your code. Git makes this process easy, safe, and well-organized by keeping a complete history of changes.</p>
<p><strong>Why “Distributed”?</strong><br />Git is called a distributed version control system because every developer has a full copy of the entire project. This means there is no single point of failure, and developers can continue working on their code even without an internet connection.</p>
<h2 id="heading-why-git-is-used">Why Git is Used?</h2>
<p>Git is used to manage and control changes in source code efficiently. It helps developers work in an organized manner, whether they are working alone or in a team.</p>
<p>Git is mainly used to:</p>
<ul>
<li><p><strong>Track code changes</strong> over time so you always know what was modified and when</p>
</li>
<li><p><strong>Collaborate with multiple developers</strong> without overwriting each other’s work</p>
</li>
<li><p><strong>Maintain complete project history</strong> with clear and meaningful commits</p>
</li>
<li><p><strong>Experiment safely using branches</strong> without affecting the main codebase</p>
</li>
<li><p><strong>Roll back mistakes easily</strong> and return to a stable version whenever needed</p>
</li>
</ul>
<h3 id="heading-without-git">Without Git</h3>
<p>Without Git, managing code becomes messy and confusing. Developers often end up creating multiple copies of the same project, such as:</p>
<ul>
<li><p>final_project.zip</p>
</li>
<li><p>final_project_v2.zip</p>
</li>
<li><p>final_project_final.zio</p>
</li>
</ul>
<p>This leads to confusion, lost changes, and wasted time.</p>
<h3 id="heading-with-git">With Git</h3>
<p>With Git, everything is structured and easy to manage:</p>
<ul>
<li><p>Clean and readable project history</p>
</li>
<li><p>Clear tracking of every change</p>
</li>
<li><p>Smooth and efficient collaboration</p>
</li>
</ul>
<p>In short, Git brings <strong>clarity, control, and confidence</strong> to the development process.</p>
<h2 id="heading-git-basics-and-core-terminologies">Git Basics and Core Terminologies</h2>
<p>Before using Git effectively, it is important to understand some core concepts. These basic terminologies form the foundation of how Git works.</p>
<p><strong>A) Repository (Repo) :</strong> A <strong>repository</strong> is a folder that Git tracks and manages. It contains our entire project along with all its version history. A Git repository includes:</p>
<ul>
<li><p>Your project files</p>
</li>
<li><p>A hidden “.<strong>git</strong>” folder, which stores Git’s data, history, and configuration (think its like a Git’s brain)</p>
</li>
<li><p>repository structure like</p>
<ul>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768042686224/47126b5c-2cfd-46d9-be59-80a15a0ca765.png" alt /></p>
<p>  The <strong>.git</strong> directory is hidden inside the <strong>LEARNGIT</strong> folder.</p>
</li>
</ul>
</li>
</ul>
<p><strong>B) Working Directory :</strong> The <strong>working directory</strong> is the place where you actively work on your code. Any changes you make here are not tracked by Git until you tell Git to track this/that file.</p>
<p>Examples of working directory actions include:</p>
<ul>
<li><p>Editing <strong>hello.txt</strong></p>
</li>
<li><p>Creating new file <strong>feature.txt</strong></p>
</li>
<li><p>Deleting or modifying existing files</p>
</li>
</ul>
<p><strong>C) Staging Area :</strong> The <strong>staging area</strong> is an intermediate step between the working directory and the repository. It allows you to select which changes should be included in the next commit.</p>
<p>You can think of it as telling Git: “I want Git to remember these specific changes (Means we tell to git “hey git take a screenshot of these changes what I made now)”.</p>
<p>For example, as shown in the figure below, the staging area works like a bridge between the working directory and the repository, helping Git decide what changes should be committed.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768043121695/f162939b-2e27-4e10-a5d7-f9413521e919.png" alt class="image--center mx-auto" /></p>
<p><strong>D) Commit :</strong> A <strong>commit</strong> is saves screenshot of our project at a specific point in time. Once committed, the changes are safely stored in the repository’s history (Means here we say to git <strong>“Hey git save the screenshot of changes“</strong> ).</p>
<p>Each commit contains:</p>
<ul>
<li><p>A unique commit ID</p>
</li>
<li><p>Author information</p>
</li>
<li><p>Date and time of the commit</p>
</li>
<li><p>A descriptive commit message example for commit message <strong>“Added login feature”</strong></p>
</li>
</ul>
<p><strong>E) Branch :</strong> A <strong>branch</strong> is an independent line of development that allows you to work on features or fixes without affecting the main codebase.</p>
<p>Common examples:</p>
<ul>
<li><p>main → stable and production-ready code</p>
</li>
<li><p>feature → experimental or feature-specific work</p>
</li>
</ul>
<p>Branches help you develop new features safely and in parallel.</p>
<p><strong>F) HEAD :</strong> A <strong>HEAD</strong> is a pointer that indicates your current position in the Git history. It tells Git which commit you are currently working on.</p>
<p>You can think of HEAD as: <strong>“Where am I right now in Git history?”</strong></p>
<h2 id="heading-common-git-commands">Common Git Commands</h2>
<p>Here are some of the most frequently used Git commands.</p>
<ol>
<li><strong>git init :</strong> This command initializes a new Git repository in our current working project directory. It creates a hidden .<strong>git</strong> folder where Git stores all its tracking information.</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768044983247/f1b01179-d0a2-4f2e-824f-ba1f8600c44f.png" alt /></p>
<ol start="2">
<li><p><strong>git add &lt;filename&gt; :</strong> his command adds specific/single file from our working directory to the staging area.</p>
</li>
<li><p><strong>git add . :</strong> This command adds all modified and new files in our current directory to the staging area. Use with caution, ensuring you only add what you intend to commit.</p>
</li>
<li><p><strong>git commit -m "commit message" :</strong> This command takes everything from the staging area and permanently saves it as a new commit in our local repository. The <strong>“-m”</strong> flag allows you to add a concise and descriptive message about the changes what we made. Ex: <strong>git commit -m "Initial commit: create user register form"</strong></p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768045490605/a37037d5-bef6-44a1-b8d4-9917e0a7ecc6.png" alt class="image--center mx-auto" /></p>
<ol start="5">
<li><p><strong>git diff :</strong> It shows the differences between files — it tells you <strong>what changes you have made</strong> compared to the last saved version of commit.</p>
</li>
<li><p><strong>git log :</strong> This command displays the commit history of your current branch. You'll see each commit's unique ID, author, date, and commit message.</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768045698636/ac3afd9b-88f9-4aea-a2a4-cffb82277f99.png" alt class="image--center mx-auto" /></p>
<ol start="7">
<li><p><strong>git revert &lt;commit-hash&gt;</strong> : it is used to <strong>undo or remove a specific changes/commit safely</strong> by creating a <strong>new commit</strong> that reverses the changes made in that commit.</p>
</li>
<li><p><strong>git reset —hard &lt;commit-hash&gt;:</strong> moves the <strong>HEAD back to an earlier commit</strong> and completely removes all commits and changes after it and You <strong>cannot recover</strong> those changes unlike <strong>git revert</strong></p>
</li>
<li><p><strong>git status :</strong> <strong>git status</strong> command that shows the current state of our repository. It helps you understand what is happening in our project at any given moment. The command tells us which files have been modified, which files are staged, which are untracked, and whether changes have been committed or not. In short, <strong>“git status”</strong> gives a complete overview of the current condition of the project.</p>
</li>
</ol>
<p>Git may feel confusing at first, but once you understand:</p>
<ul>
<li><p>Repository</p>
</li>
<li><p>Staging</p>
</li>
<li><p>Commit</p>
</li>
<li><p>Branch</p>
</li>
</ul>
<p>it becomes <strong>one of the most powerful tools</strong> in your developer journey.</p>
]]></content:encoded></item></channel></rss>