<?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[Basic_commands_git]]></title><description><![CDATA[Basic_commands_git]]></description><link>https://commands-git.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Tue, 15 Sep 2026 16:45:16 GMT</lastBuildDate><atom:link href="https://commands-git.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[✍️Introduction:
When I started learning programming, I used to save my project files like this:
project_final.zipproject_final_v2.zipproject_final_really_final.zip
Very soon, I realized this was messy and confusing.That’s when I learned why developer...]]></description><link>https://commands-git.hashnode.dev/git-for-beginners-basics-and-essential-commands</link><guid isPermaLink="true">https://commands-git.hashnode.dev/git-for-beginners-basics-and-essential-commands</guid><category><![CDATA[git  version-control  programming  web-development]]></category><dc:creator><![CDATA[Joydeep Garai]]></dc:creator><pubDate>Fri, 16 Jan 2026 12:29:24 GMT</pubDate><content:encoded><![CDATA[<h2 id="heading-introduction">✍️Introduction:</h2>
<p>When I started learning programming, I used to save my project files like this:</p>
<p>project_final.zip<br />project_final_v2.zip<br />project_final_really_final.zip</p>
<p>Very soon, I realized this was messy and confusing.<br />That’s when I learned why developers use <strong>Git</strong>.</p>
<p>In this blog, I’ll explain what Git is, why it is used, and how beginners can start using Git step by step.</p>
<h2 id="heading-what-is-git">✍️What is Git?</h2>
<p>In simple language git means version control system, track changes and helps developer to work safely.</p>
<p>But more <strong>technica</strong>l way: <strong>Git</strong> is a <strong>distributed version control system</strong> to track changes in source code during development.</p>
<p>Now you think what is <strong>version control system?? It’s nothing but in simple way:</strong> It keeps a history of your work and allows you to go back to any previous version whenever needed.</p>
<p><strong>Every developer use Git as a complete copy of the entire project on their own system.</strong></p>
<h2 id="heading-why-git-is-used">✍️Why Git is used?</h2>
<p>Git is used because it solves many real-world problems:</p>
<h2 id="heading-1-losing-code-by-mistake">1. Losing Code by Mistake ❌</h2>
<p><strong>Problem:</strong><br />You delete or overwrite a working file and can’t recover it.</p>
<p><strong>How Git Helps:</strong><br />Git keeps a <strong>complete history</strong> of every change.<br />You can easily go back to a previous working version.</p>
<h2 id="heading-2-multiple-people-editing-the-same-file">2. Multiple People Editing the Same File 🧑‍🤝‍🧑</h2>
<p><strong>Problem:</strong><br />Two developers change the same file and one person’s work gets lost.</p>
<p><strong>How Git Helps:</strong><br />Git <strong>merges changes safely</strong> and shows conflicts if any.</p>
<p>👉 <strong><em>Real life:</em></strong> Google Docs but for code</p>
<h2 id="heading-3-confusing-file-versions">3. Confusing File Versions 📁</h2>
<p><strong>Problem:</strong><br />Files like:</p>
<pre><code class="lang-plaintext">final.cpp
final_v2.cpp
final_latest.cpp
final_latest_fixed.cpp
</code></pre>
<p><strong>How Git Helps:</strong><br />Git stores versions internally using <strong>commits</strong> with messages.</p>
<p>👉 <strong><em>Real life*</em></strong>:* Clean history instead of messy file names</p>
<h2 id="heading-4-experimenting-without-fear">4. Experimenting Without Fear 🧪</h2>
<p><strong>Problem:</strong><br />You’re scared to try a new feature because it may break the code.</p>
<p><strong>How Git Helps:</strong><br />You can create a <strong>branch</strong>, test freely, and discard it if it fails.</p>
<p>👉 <strong><em>Real life:</em></strong> Like testing ideas in a <strong>separate notebook</strong></p>
<h2 id="heading-5-tracking-who-changed-what">5. Tracking Who Changed What 🕵️</h2>
<p><strong>Problem:</strong><br />A bug appears and no one knows <strong>who caused it</strong>.</p>
<p><strong>How Git Helps:</strong><br />Git shows:</p>
<ul>
<li><p>Who changed the code</p>
</li>
<li><p>When it was changed</p>
</li>
<li><p>Why (commit message)</p>
</li>
</ul>
<p>👉 <strong><em>Real life:</em></strong> CCTV for code changes</p>
<h2 id="heading-6-fixing-bugs-faster">6. Fixing Bugs Faster 🐞</h2>
<p><strong>Problem:</strong><br />You don’t know which change introduced a bug.</p>
<p><strong>How Git Helps:</strong><br />You can:</p>
<ul>
<li><p>Compare versions</p>
</li>
<li><p>Go back to a stable commit</p>
</li>
<li><p>Identify the faulty change</p>
</li>
</ul>
<p>👉 <strong><em>Real life:</em></strong> Time-travel to find mistakes</p>
<h2 id="heading-7-working-offline">7. Working Offline 🌐</h2>
<p><strong>Problem:</strong><br />No internet but you still want to code and save progress.</p>
<p><strong>How Git Helps:</strong><br />Git works <strong>offline</strong> and syncs later when online.</p>
<p>👉 <strong><em>Real life:</em></strong> Notes app that syncs when internet is back</p>
<p>💡<strong><em>Because of these reasons, Git is used in almost every software company today.</em></strong></p>
<h2 id="heading-git-basics-and-core-terminologies">✍️Git basics and Core Terminologies:</h2>
<h3 id="heading-before-learning-git-commands-or-terms-its-important-to-understand-how-git-works-behind-the-scenes">Before learning Git commands or terms, it’s important to understand <strong>how Git works behind the scenes</strong>.</h3>
<p>Git works in <strong>three main stages</strong>:</p>
<ol>
<li><p><strong>Working Directory</strong></p>
</li>
<li><p><strong>Staging Area</strong></p>
</li>
<li><p><strong>Repository</strong></p>
</li>
</ol>
<h3 id="heading-diagram-git-basic-workflow">📌 Diagram: Git Basic Workflow</h3>
<pre><code class="lang-plaintext">Working Directory → Staging Area → Repository
</code></pre>
<h2 id="heading-repository-repo">🔹Repository (Repo)</h2>
<p>A <strong>repository</strong> is a folder where Git tracks all changes of your project.</p>
<p>It contains:</p>
<ul>
<li><p>Your project files</p>
</li>
<li><p>Complete history of changes</p>
</li>
<li><p>Information about commits and branches</p>
</li>
</ul>
<p>You create a repository using:</p>
<pre><code class="lang-plaintext">git init
</code></pre>
<p>📘 <strong>Real-life example:</strong><br />A repository is like a Google Drive folder that remembers every edit you’ve ever made.</p>
<hr />
<h2 id="heading-working-directory">Working Directory</h2>
<p>The <strong>working directory</strong> is where you actually write and modify your code.</p>
<p>Whenever you:</p>
<ul>
<li><p>Create a file</p>
</li>
<li><p>Edit code in VS Code</p>
</li>
<li><p>Delete or update a file</p>
</li>
</ul>
<p>You are working inside the <strong>working directory</strong>.</p>
<p>📝 These changes are <strong>not saved by Git automatically</strong> until you tell Git to save them.</p>
<h2 id="heading-staging-area">Staging Area</h2>
<p>The <strong>staging area</strong> is a temporary place where you select which changes should be saved.</p>
<p>You use the staging area to tell Git:</p>
<blockquote>
<p>“These are the changes I want to include in my next save.”</p>
</blockquote>
<p>Command used:</p>
<pre><code class="lang-plaintext">git add filename
</code></pre>
<p>or to add everything:</p>
<pre><code class="lang-plaintext">git add .
</code></pre>
<p>📘 <strong>Real-life example:</strong><br />Like selecting photos before uploading them to Instagram.</p>
<h2 id="heading-commit">🔹Commit</h2>
<p>A <strong>commit</strong> is a permanent snapshot of your project at a specific point in time.</p>
<p>Each commit includes:</p>
<ul>
<li><p>A unique ID</p>
</li>
<li><p>A message describing the change</p>
</li>
<li><p>Date and time</p>
</li>
</ul>
<p>Command:</p>
<pre><code class="lang-plaintext">git commit -m "Added login feature"
</code></pre>
<p>📘 <strong>Important:</strong><br />Once a commit is created, you can always go back to it.</p>
<h2 id="heading-branch">🔹Branch</h2>
<p>A <strong>branch</strong> allows you to work on new features or experiments <strong>without affecting the main code</strong>.</p>
<p>By default, Git creates a branch called <strong>main</strong>.</p>
<h3 id="heading-diagram-branching-in-git">📌 Diagram: Branching in Git</h3>
<pre><code class="lang-plaintext">main
  |
  |── feature-login
  |
  |── bug-fix
</code></pre>
<p>Another view:</p>
<pre><code class="lang-plaintext">A ── B ── C (main)
          \
           D ── E (feature branch)
</code></pre>
<p>📘 <strong>Real-life example:</strong><br />Like writing rough work on a separate notebook page while keeping the main notes clean.</p>
<hr />
<h2 id="heading-head">🔹HEAD</h2>
<p><strong>HEAD</strong> is a pointer that shows:</p>
<blockquote>
<p>Where you are currently working in Git</p>
</blockquote>
<p>If you switch branches, <strong>HEAD moves with you</strong>.</p>
<p>📘 Simply put:<br />HEAD = <em>your current position in the project.</em></p>
<h3 id="heading-now-come-to-all-common-git-commands">😀<strong>Now come to all common Git commands:</strong></h3>
<h2 id="heading-git-init-initialize-a-repository">🟢 git init — Initialize a Repository</h2>
<p>Initializes a new Git repository in the current project directory.</p>
<pre><code class="lang-plaintext">git init
</code></pre>
<p><strong>Purpose:</strong></p>
<ul>
<li><p>Starts Git tracking for a project</p>
</li>
<li><p>Creates a <code>.git</code> directory</p>
</li>
</ul>
<p>Use this command <strong>once</strong> when starting a new project.</p>
<h2 id="heading-git-status-check-repository-status">🟢 git status — Check Repository Status</h2>
<p>Displays the current state of the working directory and staging area.</p>
<pre><code class="lang-plaintext">git status
</code></pre>
<p><strong>Shows:</strong></p>
<ul>
<li><p>Modified files</p>
</li>
<li><p>Staged files</p>
</li>
<li><p>Untracked files</p>
</li>
</ul>
<p>This command is useful to understand what changes are pending.</p>
<h2 id="heading-git-add-stage-changes">🟢 git add — Stage Changes</h2>
<p>Moves changes from the working directory to the staging area.</p>
<p>Add a specific file:</p>
<pre><code class="lang-plaintext">git add filename
</code></pre>
<p>Add all changes:</p>
<pre><code class="lang-plaintext">git add .
</code></pre>
<p><strong>Purpose:</strong></p>
<ul>
<li>Prepares changes for commit</li>
</ul>
<hr />
<h2 id="heading-git-commit-save-changes">🟢 git commit — Save Changes</h2>
<p>Records staged changes permanently in the repository.</p>
<pre><code class="lang-plaintext">git commit -m "Commit message"
</code></pre>
<p><strong>Purpose:</strong></p>
<ul>
<li><p>Creates a snapshot of the project</p>
</li>
<li><p>Stores changes with a descriptive message</p>
</li>
</ul>
<p>Commit messages should clearly describe the change.</p>
<h2 id="heading-git-log-view-commit-history">🟢 git log — View Commit History</h2>
<p>Displays the commit history of the repository.</p>
<pre><code class="lang-plaintext">git log
</code></pre>
<p><strong>Shows:</strong></p>
<ul>
<li><p>Commit hash</p>
</li>
<li><p>Author</p>
</li>
<li><p>Date and time</p>
</li>
<li><p>Commit message</p>
</li>
</ul>
<p>Useful for tracking changes over time.</p>
<h2 id="heading-git-diff-view-file-differences">🟢 git diff — View File Differences</h2>
<p>Shows differences between modified files and the last committed version.</p>
<pre><code class="lang-plaintext">git diff
</code></pre>
<p><strong>Purpose:</strong></p>
<ul>
<li>Review changes before staging or committing</li>
</ul>
<h2 id="heading-git-branch-manage-branches">🟢 git branch — Manage Branches</h2>
<p>Lists, creates, or deletes branches.</p>
<p>List branches:</p>
<pre><code class="lang-plaintext">git branch
</code></pre>
<p>Create a new branch:</p>
<pre><code class="lang-plaintext">git branch branch-name
</code></pre>
<p><strong>Purpose:</strong></p>
<ul>
<li>Enables parallel development</li>
</ul>
<h2 id="heading-git-checkout-switch-branches">🟢 git checkout — Switch Branches</h2>
<p>Switches between branches or commits.</p>
<pre><code class="lang-plaintext">git checkout branch-name
</code></pre>
<p><strong>Purpose:</strong></p>
<ul>
<li>Move the HEAD pointer to another branch</li>
</ul>
<h2 id="heading-git-merge-merge-branches">🟢 git merge — Merge Branches</h2>
<p>Combines changes from one branch into the current branch.</p>
<pre><code class="lang-plaintext">git merge branch-name
</code></pre>
<p><strong>Purpose:</strong></p>
<ul>
<li>Integrates completed work into another branch</li>
</ul>
<h2 id="heading-git-clone-copy-a-repository">🟢 git clone — Copy a Repository</h2>
<p>Creates a local copy of a remote repository.</p>
<pre><code class="lang-plaintext">git clone repository-url
</code></pre>
<p><strong>Purpose:</strong></p>
<ul>
<li>Download an existing project to your system</li>
</ul>
<h2 id="heading-git-pull-fetch-and-merge-changes">🟢 git pull — Fetch and Merge Changes</h2>
<p>Fetches updates from a remote repository and merges them into the current branch.</p>
<pre><code class="lang-plaintext">git pull
</code></pre>
<p><strong>Purpose:</strong></p>
<ul>
<li>Keep the local repository up to date</li>
</ul>
<h2 id="heading-git-push-upload-local-changes">🟢 git push — Upload Local Changes</h2>
<p>Uploads local commits to a remote repository.</p>
<pre><code class="lang-plaintext">git push
</code></pre>
<p><strong>Purpose:</strong></p>
<ul>
<li>Share changes with others</li>
</ul>
<h2 id="heading-git-remote-manage-remote-repositories">🟢 git remote — Manage Remote Repositories</h2>
<p>Displays or manages remote repository connections.</p>
<pre><code class="lang-plaintext">git remote -v
</code></pre>
<p><strong>Purpose:</strong></p>
<ul>
<li><p>View linked remote URLs</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768566440966/8f6c54b0-4f89-42e3-86d1-4decc400df4f.gif" alt class="image--center mx-auto" /></p>
<h3 id="heading-final-thoughts">😀😀Final Thoughts:</h3>
<p>  Git may look complicated at first, but it becomes much simpler once you understand the purpose of each command. Focus on learning the basics well instead of trying to remember everything at once.</p>
<p>  Mistakes are part of the learning process, and Git is designed to help you recover from them. With consistent practice, these commands will soon feel natural.</p>
<p>  Up next, we will explore a <strong>complete Git workflow</strong> that beginners can follow in real projects.</p>
</li>
</ul>
]]></content:encoded></item></channel></rss>