<?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 Begineers]]></title><description><![CDATA[Git for Begineers]]></description><link>https://git-for-begineers.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 19 Sep 2026 19:34:59 GMT</lastBuildDate><atom:link href="https://git-for-begineers.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Inside Git: How It Works and the Role of the .git Folder]]></title><description><![CDATA[If you understand how Git works internally, you stop memorizing commands and start thinking like Git.
Let’s build a strong mental model step-by-step.

🧠 Big Picture: What Git Really Is
👉 Git is a content tracker, not a file tracker.
Most people thi...]]></description><link>https://git-for-begineers.hashnode.dev/inside-git-how-it-works-and-the-role-of-the-git-folder</link><guid isPermaLink="true">https://git-for-begineers.hashnode.dev/inside-git-how-it-works-and-the-role-of-the-git-folder</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[Git]]></category><category><![CDATA[version control]]></category><dc:creator><![CDATA[Irfan Ahmad]]></dc:creator><pubDate>Thu, 12 Feb 2026 09:28:31 GMT</pubDate><content:encoded><![CDATA[<p>If you understand <strong>how Git works internally</strong>, you stop memorizing commands and start <em>thinking like Git</em>.</p>
<p>Let’s build a strong mental model step-by-step.</p>
<hr />
<h1 id="heading-big-picture-what-git-really-is">🧠 Big Picture: What Git Really Is</h1>
<p>👉 <strong>Git is a content tracker, not a file tracker.</strong></p>
<p>Most people think:</p>
<blockquote>
<p>“Git tracks files.”</p>
</blockquote>
<p>But internally:</p>
<blockquote>
<p><strong>Git tracks snapshots of content using hashes.</strong></p>
</blockquote>
<p>Every time you commit, Git stores a <strong>snapshot of your project</strong> — not just the changes.</p>
<hr />
<h1 id="heading-understanding-the-git-folder">📁 Understanding the <code>.git</code> Folder</h1>
<p>When you run:</p>
<pre><code class="lang-plaintext">git init
</code></pre>
<p>Git creates a hidden folder:</p>
<pre><code class="lang-plaintext">.git/
</code></pre>
<p>This folder is the <strong>entire Git repository database</strong>.</p>
<p>If you delete <code>.git</code> → your Git history is gone.</p>
<hr />
<h2 id="heading-whats-inside-git">📦 What’s Inside <code>.git</code>?</h2>
<p>Typical structure:</p>
<pre><code class="lang-plaintext">.git/
 ├── objects/
 ├── refs/
 ├── HEAD
 ├── index
 └── config
</code></pre>
<p>Let’s understand these conceptually.</p>
<hr />
<h2 id="heading-1-objects-the-database">1️⃣ <code>objects/</code> → The Database</h2>
<p>This is where Git stores <strong>everything</strong>:</p>
<ul>
<li><p>File contents</p>
</li>
<li><p>Directory structures</p>
</li>
<li><p>Commits</p>
</li>
</ul>
<p>All stored as compressed objects.</p>
<p>👉 This is Git’s heart.</p>
<hr />
<h2 id="heading-2-refs-branches">2️⃣ <code>refs/</code> → Branches</h2>
<p>Stores pointers to commits.</p>
<p>Example:</p>
<pre><code class="lang-plaintext">refs/heads/main
</code></pre>
<p>This contains a commit hash.</p>
<p>Branches are just:</p>
<blockquote>
<p>A pointer to a commit.</p>
</blockquote>
<p>Nothing more.</p>
<hr />
<h2 id="heading-3-head">3️⃣ <code>HEAD</code></h2>
<p><code>HEAD</code> tells Git:</p>
<blockquote>
<p>“Which branch am I currently on?”</p>
</blockquote>
<p>Example:</p>
<pre><code class="lang-plaintext">ref: refs/heads/main
</code></pre>
<hr />
<h2 id="heading-4-index-staging-area">4️⃣ <code>index</code> → Staging Area</h2>
<p>This is the <strong>staging area</strong>.</p>
<p>When you run:</p>
<pre><code class="lang-plaintext">git add file.txt
</code></pre>
<p>Git updates this <code>index</code> file.</p>
<hr />
<h1 id="heading-git-objects-core-concept">🧱 Git Objects (Core Concept)</h1>
<p>Git stores everything as <strong>objects</strong>.</p>
<p>There are only <strong>3 main types</strong>:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Type</td><td>What it stores</td></tr>
</thead>
<tbody>
<tr>
<td>Blob</td><td>File content</td></tr>
<tr>
<td>Tree</td><td>Directory structure</td></tr>
<tr>
<td>Commit</td><td>Snapshot + metadata</td></tr>
</tbody>
</table>
</div><hr />
<h1 id="heading-1-blob-binary-large-object">1️⃣ Blob (Binary Large Object)</h1>
<p>Blob = <strong>file content only</strong></p>
<p>It does NOT store:</p>
<ul>
<li><p>File name</p>
</li>
<li><p>Folder path</p>
</li>
</ul>
<p>Only raw content.</p>
<p>Example:</p>
<p>File:</p>
<pre><code class="lang-plaintext">hello.txt
Hello World
</code></pre>
<p>Git creates a blob for:</p>
<pre><code class="lang-plaintext">Hello World
</code></pre>
<hr />
<h1 id="heading-2-tree">2️⃣ Tree</h1>
<p>Tree = <strong>folder structure</strong></p>
<p>It connects:</p>
<ul>
<li><p>File names</p>
</li>
<li><p>Blob hashes</p>
</li>
<li><p>Subdirectories</p>
</li>
</ul>
<p>Think of it like:</p>
<pre><code class="lang-plaintext">project/
 ├── hello.txt
 └── app.js
</code></pre>
<p>Tree stores:</p>
<ul>
<li><p>"hello.txt" → blob hash</p>
</li>
<li><p>"app.js" → blob hash</p>
</li>
</ul>
<hr />
<h1 id="heading-3-commit">3️⃣ Commit</h1>
<p>Commit stores:</p>
<ul>
<li><p>Tree hash (snapshot)</p>
</li>
<li><p>Parent commit hash</p>
</li>
<li><p>Author</p>
</li>
<li><p>Date</p>
</li>
<li><p>Message</p>
</li>
</ul>
<p>Think of commit like:</p>
<pre><code class="lang-plaintext">Commit:
  points to → Tree
  parent → previous commit
</code></pre>
<p>This creates a chain.</p>
<hr />
<h1 id="heading-how-git-uses-hashes">🔐 How Git Uses Hashes</h1>
<p>Git uses SHA-1 hash (40 character string).</p>
<p>Example:</p>
<pre><code class="lang-plaintext">e99a18c428cb38d5f260853678922e03abd8334
</code></pre>
<p>The hash is generated from:</p>
<pre><code class="lang-plaintext">content + metadata
</code></pre>
<p>If you change even 1 character → completely new hash.</p>
<hr />
<h2 id="heading-why-hashes-matter">Why Hashes Matter</h2>
<ol>
<li><p>Unique identity</p>
</li>
<li><p>Detects tampering</p>
</li>
<li><p>Ensures integrity</p>
</li>
<li><p>Makes Git fast</p>
</li>
</ol>
<p>If content changes → hash changes → Git knows it's different.</p>
<hr />
<h1 id="heading-what-happens-during-git-add-internally">⚙️ What Happens During <code>git add</code> (Internally)</h1>
<p>Suppose you create:</p>
<pre><code class="lang-plaintext">hello.txt
</code></pre>
<h3 id="heading-step-1-you-run">Step 1: You run</h3>
<pre><code class="lang-plaintext">git add hello.txt
</code></pre>
<h3 id="heading-internally-git">Internally Git:</h3>
<ol>
<li><p>Reads file content</p>
</li>
<li><p>Creates a blob object</p>
</li>
<li><p>Generates SHA-1 hash</p>
</li>
<li><p>Stores blob in:</p>
<pre><code class="lang-plaintext"> .git/objects/
</code></pre>
</li>
<li><p>Updates the index (staging area)</p>
</li>
</ol>
<p>Important:</p>
<blockquote>
<p>No commit yet. Just staged snapshot.</p>
</blockquote>
<hr />
<h1 id="heading-what-happens-during-git-commit">⚙️ What Happens During <code>git commit</code></h1>
<p>When you run:</p>
<pre><code class="lang-plaintext">git commit -m "First commit"
</code></pre>
<p>Internally:</p>
<ol>
<li><p>Git reads index</p>
</li>
<li><p>Creates a tree object (directory snapshot)</p>
</li>
<li><p>Creates commit object</p>
<ul>
<li><p>Points to tree</p>
</li>
<li><p>Points to parent commit</p>
</li>
</ul>
</li>
<li><p>Updates branch pointer</p>
</li>
<li><p>HEAD now points to new commit</p>
</li>
</ol>
<p>Now snapshot is permanent.</p>
<hr />
<h1 id="heading-how-git-tracks-changes">🔁 How Git Tracks Changes</h1>
<p>Important concept:</p>
<p>Git does NOT store:</p>
<blockquote>
<p>“Difference between versions”</p>
</blockquote>
<p>Git stores:</p>
<blockquote>
<p>“Full snapshots”</p>
</blockquote>
<p>But it’s smart.</p>
<p>If file hasn't changed:</p>
<ul>
<li><p>It reuses old blob</p>
</li>
<li><p>Doesn’t duplicate storage</p>
</li>
</ul>
<p>So internally:</p>
<pre><code class="lang-plaintext">Commit 1 → blob A
Commit 2 → blob A (same)
</code></pre>
<p>No duplication.</p>
<hr />
<h1 id="heading-mental-model-of-git-very-important">🧠 Mental Model of Git (Very Important)</h1>
<p>Think of Git like:</p>
<h3 id="heading-a-camera-system">📸 A Camera System</h3>
<ul>
<li><p><code>git add</code> → Put files in photo frame</p>
</li>
<li><p><code>git commit</code> → Take a photo</p>
</li>
<li><p>Branch → Label pointing to a photo</p>
</li>
<li><p>HEAD → Current camera position</p>
</li>
</ul>
<p>Each commit:<br />📸 Snapshot of whole project</p>
<hr />
<h1 id="heading-how-everything-connects">🔗 How Everything Connects</h1>
<pre><code class="lang-plaintext">HEAD
  ↓
Branch (main)
  ↓
Commit
  ↓
Tree
  ↓
Blobs
</code></pre>
<p>That’s the internal chain.</p>
<hr />
<h1 id="heading-why-git-is-powerful">🚀 Why Git Is Powerful</h1>
<p>Because:</p>
<ol>
<li><p>Everything is content-based</p>
</li>
<li><p>Everything is immutable</p>
</li>
<li><p>Everything is linked by hashes</p>
</li>
<li><p>Branches are lightweight pointers</p>
</li>
</ol>
<p>Branch creation:</p>
<pre><code class="lang-plaintext">Just create new pointer to commit.
</code></pre>
<p>That’s why branching is fast.</p>
<hr />
<h1 id="heading-advanced-insight-but-simple">💡 Advanced Insight (But Simple)</h1>
<p>Git is basically:</p>
<blockquote>
<p>A key-value database</p>
</blockquote>
<p>Where:</p>
<pre><code class="lang-plaintext">Key   = SHA-1 hash
Value = Object content
</code></pre>
<p>That’s it.</p>
<hr />
<h1 id="heading-final-mental-model-summary">🏗 Final Mental Model Summary</h1>
<p>Git is:</p>
<ul>
<li><p>A content-addressable storage system</p>
</li>
<li><p>That stores snapshots</p>
</li>
<li><p>Connected by hashes</p>
</li>
<li><p>With lightweight branch pointers</p>
</li>
</ul>
<hr />
<h1 id="heading-if-you-remember-only-5-things">🔥 If You Remember Only 5 Things</h1>
<ol>
<li><p>Git stores snapshots, not diffs.</p>
</li>
<li><p>Everything is stored in <code>.git</code>.</p>
</li>
<li><p>Blob = file content.</p>
</li>
<li><p>Tree = folder structure.</p>
</li>
<li><p>Commit = snapshot + metadata.</p>
</li>
</ol>
<p>Diagram for the understanding:-</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1770888408323/ee8b678e-73bd-4778-a2f3-6c51a2c79941.jpeg" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Why Version Control Exists: The Pendrive Problem]]></title><description><![CDATA[🚨 Why Version Control Exists
Today we use Git and think it’s normal.
But imagine this:
👉 No Git👉 No GitHub👉 No cloud👉 Just folders and pendrives
That’s how development worked earlier.
And it was a mess.

💾 The Pendrive Analogy in Software Devel...]]></description><link>https://git-for-begineers.hashnode.dev/why-version-control-exists-the-pendrive-problem</link><guid isPermaLink="true">https://git-for-begineers.hashnode.dev/why-version-control-exists-the-pendrive-problem</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[Git]]></category><category><![CDATA[version control]]></category><dc:creator><![CDATA[Irfan Ahmad]]></dc:creator><pubDate>Tue, 10 Feb 2026 18:30:00 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-why-version-control-exists">🚨 Why Version Control Exists</h1>
<p>Today we use Git and think it’s normal.</p>
<p>But imagine this:</p>
<p>👉 No Git<br />👉 No GitHub<br />👉 No cloud<br />👉 Just folders and pendrives</p>
<p>That’s how development worked earlier.</p>
<p>And it was a mess.</p>
<hr />
<h1 id="heading-the-pendrive-analogy-in-software-development">💾 The Pendrive Analogy in Software Development</h1>
<p>Let’s imagine 3 developers working on a project:</p>
<ul>
<li><p>Irfan</p>
</li>
<li><p>Aamir</p>
</li>
<li><p>Rahul</p>
</li>
</ul>
<p>They are building a website.</p>
<p>There is no Git.</p>
<p>What do they do?</p>
<hr />
<h2 id="heading-step-1-single-developer-situation">🧍 Step 1: Single Developer Situation</h2>
<p>You create a project folder:</p>
<pre><code class="lang-plaintext">project/
</code></pre>
<p>You make changes.</p>
<p>Before trying something risky, you copy the folder:</p>
<pre><code class="lang-plaintext">project_final
project_final2
project_latest
project_latest_final
project_latest_final_REAL
</code></pre>
<p>Sound familiar? 😅</p>
<p>This is manual version control.</p>
<hr />
<h2 id="heading-problem-1-folder-chaos">❌ Problem 1: Folder Chaos</h2>
<p>After 2 weeks, your desktop looks like:</p>
<pre><code class="lang-plaintext">project
project_new
project_new2
project_final
project_final_v2
project_final_v2_updated
project_latest_final_working
</code></pre>
<p>Now question:</p>
<p>👉 Which one is correct?<br />👉 Which one is deployed?<br />👉 Which one has latest bug fix?</p>
<p>You don’t know.</p>
<hr />
<h2 id="heading-step-2-multiple-developers-pendrive-era">👥 Step 2: Multiple Developers (Pendrive Era)</h2>
<p>Now imagine team collaboration.</p>
<p>Irfan works on his laptop.<br />He copies project into pendrive.<br />Gives it to Aamir.</p>
<p>Aamir:</p>
<ul>
<li><p>Makes changes</p>
</li>
<li><p>Overwrites some files</p>
</li>
<li><p>Adds new features</p>
</li>
</ul>
<p>Then gives pendrive to Rahul.</p>
<p>Meanwhile…</p>
<p>Irfan also made changes on his laptop.</p>
<p>Now we have:</p>
<ul>
<li><p>Irfan’s version</p>
</li>
<li><p>Aamir’s version</p>
</li>
<li><p>Rahul’s version</p>
</li>
</ul>
<p>All different.</p>
<hr />
<h1 id="heading-major-problems-before-version-control">❌ Major Problems Before Version Control</h1>
<p>Let’s break them down clearly.</p>
<hr />
<h2 id="heading-1-overwriting-code">1️⃣ Overwriting Code</h2>
<p>Example:</p>
<p>Irfan edits:</p>
<pre><code class="lang-plaintext">login.js
</code></pre>
<p>At the same time, Aamir edits:</p>
<pre><code class="lang-plaintext">login.js
</code></pre>
<p>Now someone copies file over pendrive.</p>
<p>💥 One person's work is gone.</p>
<p>No warning.<br />No merge.<br />No history.</p>
<p>Just overwritten.</p>
<hr />
<h2 id="heading-2-losing-changes">2️⃣ Losing Changes</h2>
<p>You delete something accidentally.</p>
<p>Or your system crashes.</p>
<p>Or you forgot to copy the correct folder.</p>
<p>💀 Changes lost forever.</p>
<p>No recovery.</p>
<hr />
<h2 id="heading-3-no-history">3️⃣ No History</h2>
<p>You find a bug.</p>
<p>You ask:</p>
<blockquote>
<p>“Who changed this file?”</p>
</blockquote>
<p>No answer.</p>
<blockquote>
<p>“When was this added?”</p>
</blockquote>
<p>No answer.</p>
<blockquote>
<p>“What was the previous version?”</p>
</blockquote>
<p>No answer.</p>
<p>Everything is manual.</p>
<hr />
<h2 id="heading-4-no-collaboration-tracking">4️⃣ No Collaboration Tracking</h2>
<p>In team:</p>
<ul>
<li><p>Who added this feature?</p>
</li>
<li><p>Who broke the code?</p>
</li>
<li><p>Why was this line removed?</p>
</li>
</ul>
<p>There was no record.</p>
<p>Just guessing.</p>
<hr />
<h2 id="heading-5-email-version-control-even-worse">5️⃣ Email Version Control (Even Worse)</h2>
<p>Developers started emailing ZIP files:</p>
<pre><code class="lang-plaintext">project_v1.zip
project_v2_new.zip
project_final.zip
project_final_revised.zip
project_final_final.zip
</code></pre>
<p>Inbox becomes nightmare.</p>
<p>Now imagine 10 developers doing this.</p>
<p>Chaos.</p>
<hr />
<h1 id="heading-real-world-team-problem-example">🧠 Real-World Team Problem Example</h1>
<p>Let’s say company has:</p>
<ul>
<li><p>Backend team</p>
</li>
<li><p>Frontend team</p>
</li>
<li><p>QA team</p>
</li>
</ul>
<p>Without version control:</p>
<p>Backend changes API.<br />Frontend doesn’t know.<br />App breaks.</p>
<p>QA tests wrong version.</p>
<p>No synchronization.</p>
<p>No central truth.</p>
<hr />
<h1 id="heading-why-this-didnt-scale">📦 Why This Didn’t Scale</h1>
<p>Small projects → manageable.</p>
<p>But large systems like:</p>
<ul>
<li><p>Windows</p>
</li>
<li><p>Linux</p>
</li>
<li><p>Facebook</p>
</li>
<li><p>Banking systems</p>
</li>
</ul>
<p>With 100+ developers?</p>
<p>Impossible without version control.</p>
<hr />
<h1 id="heading-the-core-problem">🔄 The Core Problem</h1>
<p>Before version control:</p>
<p>Everything was:</p>
<ul>
<li><p>Manual</p>
</li>
<li><p>Unstructured</p>
</li>
<li><p>Risky</p>
</li>
<li><p>Untraceable</p>
</li>
</ul>
<p>Developers needed:</p>
<p>✔ History<br />✔ Backup<br />✔ Collaboration<br />✔ Accountability<br />✔ Safe experimentation</p>
<hr />
<h1 id="heading-so-what-was-the-solution">💡 So What Was the Solution?</h1>
<p>Version Control Systems (VCS).</p>
<p>Instead of copying folders manually:</p>
<p>We let a system:</p>
<ul>
<li><p>Track every change</p>
</li>
<li><p>Record who made it</p>
</li>
<li><p>Store history</p>
</li>
<li><p>Allow collaboration safely</p>
</li>
<li><p>Recover old versions</p>
</li>
</ul>
<hr />
<h1 id="heading-mental-shift">🧠 Mental Shift</h1>
<p>Old mindset:</p>
<blockquote>
<p>“Save new folder every time.”</p>
</blockquote>
<p>New mindset:</p>
<blockquote>
<p>“Let system track changes automatically.”</p>
</blockquote>
<hr />
<h1 id="heading-why-version-control-became-mandatory">🌍 Why Version Control Became Mandatory</h1>
<p>Because modern development requires:</p>
<h3 id="heading-1-multiple-developers">1️⃣ Multiple Developers</h3>
<p>People work simultaneously.</p>
<h3 id="heading-2-continuous-updates">2️⃣ Continuous Updates</h3>
<p>Software never stops evolving.</p>
<h3 id="heading-3-safe-experimentation">3️⃣ Safe Experimentation</h3>
<p>Developers need branches.</p>
<h3 id="heading-4-accountability">4️⃣ Accountability</h3>
<p>Every change must be traceable.</p>
<h3 id="heading-5-backup-amp-recovery">5️⃣ Backup &amp; Recovery</h3>
<p>Nothing should be permanently lost.</p>
<hr />
<h1 id="heading-connecting-back-to-git">🔗 Connecting Back to Git</h1>
<p>Git solves pendrive problems by:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Pendrive Problem</td><td>Git Solution</td></tr>
</thead>
<tbody>
<tr>
<td>Folder chaos</td><td>Commit history</td></tr>
<tr>
<td>Overwriting code</td><td>Merge system</td></tr>
<tr>
<td>Lost changes</td><td>Full history</td></tr>
<tr>
<td>No collaboration</td><td>Distributed model</td></tr>
<tr>
<td>No tracking</td><td>Author + timestamp</td></tr>
</tbody>
</table>
</div><hr />
<h1 id="heading-the-big-realization">🧭 The Big Realization</h1>
<p>Version control is not just a tool.</p>
<p>It is:</p>
<blockquote>
<p>A time machine for your code.</p>
</blockquote>
<p>You can:</p>
<ul>
<li><p>Go back in time</p>
</li>
<li><p>See who changed what</p>
</li>
<li><p>Undo mistakes</p>
</li>
<li><p>Create parallel universes (branches)</p>
</li>
<li><p>Merge realities</p>
</li>
</ul>
<p>Diagram for the understanding:-</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1770888879659/00952853-6972-4441-9ffd-00ab3f149e88.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Git for Beginners]]></title><description><![CDATA[What is Git

Git is a Distributed Version Control System (DVCS) used to track changes in files and source code during software development.

Git is a distributed version control system that manages and tracks project changes efficiently.


Why is use...]]></description><link>https://git-for-begineers.hashnode.dev/git-for-beginner</link><guid isPermaLink="true">https://git-for-begineers.hashnode.dev/git-for-beginner</guid><category><![CDATA[Git]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[Chaiaurcode]]></category><dc:creator><![CDATA[Irfan Ahmad]]></dc:creator><pubDate>Sun, 25 Jan 2026 07:25:40 GMT</pubDate><content:encoded><![CDATA[<h3 id="heading-what-is-git"><strong>What is Git</strong></h3>
<ul>
<li><p><strong>Git</strong> is a <strong>Distributed Version Control System (DVCS)</strong> used to <strong>track changes in files and source code</strong> during software development.</p>
</li>
<li><p>Git is a distributed version control system that manages and tracks project changes efficiently.</p>
</li>
</ul>
<h3 id="heading-why-is-used-git"><strong>Why is used Git</strong></h3>
<ul>
<li><p>Git is used to <strong>manage, track, and control changes in source code</strong> during software development.</p>
<ul>
<li><p><strong>Tracks Code History:</strong> Saves every change, so you can return to any previous version.</p>
</li>
<li><p><strong>Enables Team Collaboration:</strong> Multiple developers can work on the same project without overwriting each other’s work.</p>
</li>
<li><p><strong>Supports Branching:</strong> Developers can create separate branches to work on new features safely.</p>
</li>
<li><p><strong>Data Integrity:</strong> Git uses cryptographically secure hashing (SHA-1) to ensure the integrity of the code and its change history, protecting against accidental or malicious corruption.</p>
</li>
</ul>
</li>
</ul>
<h3 id="heading-common-git-commands"><strong>Common Git Commands:</strong></h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td><code>git init</code></td><td>Initialises a new git repository in the current directory</td></tr>
</thead>
<tbody>
<tr>
<td><code>git clone &lt;url&gt;</code></td><td>Creates a local copy of a remote repository from specific URL, including all its files, history and branches</td></tr>
<tr>
<td><code>git status</code></td><td>Shows the status of changes as untracked, modified, or staged in the working directory</td></tr>
<tr>
<td><code>git add &lt;file_name&gt;</code></td><td>Stages a change, adding a file or changes in a file to the staging area, which is the next snapshot to be committed</td></tr>
<tr>
<td><code>git add .</code></td><td>Stages all new changes and modified files in the current directory and its subdirectories</td></tr>
<tr>
<td><code>git commit -m &lt;message&gt;</code></td><td>Saves the staged snapshot to the project history with a descriptive message</td></tr>
<tr>
<td><code>git diff</code></td><td>Show the difference between the working directory and the staging area</td></tr>
<tr>
<td><code>git branch</code></td><td>Lists all local branches in the repository</td></tr>
<tr>
<td><code>git branch &lt;branch_name&gt;</code></td><td>Creates a new local branch</td></tr>
<tr>
<td><code>git checkout &lt;branch_name&gt;</code></td><td>Switches to the specified branch or a previous commit</td></tr>
<tr>
<td><code>git checkout -b &lt;new_branch_name&gt;</code></td><td>Creates a new branch and switches to it in one command</td></tr>
<tr>
<td><code>git merge &lt;branch&gt;</code></td><td>Merges changes from the specified branch into the current active branch</td></tr>
<tr>
<td><code>git remote add &lt;alias&gt; &lt;url&gt;</code></td><td>Adds a remote repository to your local configuration</td></tr>
<tr>
<td><code>git push &lt;remote&gt; &lt;branch&gt;</code></td><td>Uploads local commits to the remote repository (eg: git push origin main)</td></tr>
<tr>
<td><code>git pull</code></td><td>Fetches changes from the remote repository and integrated them into the current local branch</td></tr>
<tr>
<td><code>git fetch</code></td><td>Downloads changes commits and refs from a remote repository into your local copy but does not automatically merge them</td></tr>
<tr>
<td><code>git log</code></td><td>Displays a log of all commits in the current branch history</td></tr>
<tr>
<td><code>git stash</code></td><td>Temporarily saves changes that are not ready to be committed, allowing you to switch branches or work on something else</td></tr>
<tr>
<td><code>git config</code></td><td>Used to set user specific configurations like make and email address before committing.</td></tr>
</tbody>
</table>
</div><h3 id="heading-git-essential-commands">Git Essential Commands</h3>
<ul>
<li><h3 id="heading-git-init">git init</h3>
<p>  Initialises a new git repository in the current directory.</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769323792841/3256919a-ad96-471f-ae97-584e05bafc69.png" alt class="image--right mx-auto mr-0" /></p>
<h3 id="heading-git-status">git status</h3>
<p>  Shows the status of changes as untracked, modified, or staged in the working directory.</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769324040976/b1487248-4d77-4376-b47c-edf9d66d3c92.png" alt class="image--center mx-auto" /></p>
<p>  <strong>git add</strong></p>
<p>  Stages a change, adding a file or changes in a file to the staging area, which is the next snapshot to be committed.</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769324316226/3bd0f4d1-d044-4e26-ad9e-a5dc42c66d3b.png" alt class="image--right mx-auto mr-0" /></p>
<p>  <strong>git Commit</strong></p>
<p>  Saves the staged snapshot to the project history with a descriptive message</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769324655813/a2a70238-e659-462a-b99c-0e918f2510ba.png" alt class="image--center mx-auto" /></p>
<p>  <strong>git log</strong></p>
<p>  Displays a log of all commits in the current branch history.</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769324796218/9e729c39-90a4-4a48-a995-9ad4262a88bb.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-basic-developer-workflow-using-git"><strong>Basic Developer Workflow Using Git</strong></h3>
<p>  Creating a local repository and initialising it with git</p>
</li>
</ul>
<pre><code class="lang-bash"><span class="hljs-built_in">cd</span> my_project
git init
</code></pre>
<p>• Clone an existing remote repository (alternative)</p>
<pre><code class="lang-bash">git <span class="hljs-built_in">clone</span> https://github.com
<span class="hljs-built_in">cd</span> repository_name
</code></pre>
<ul>
<li>Create a new branch</li>
</ul>
<pre><code class="lang-bash">git checkout -b feature/my-new-feature
</code></pre>
<ul>
<li><p>Make changes</p>
<ul>
<li><p>Modify files, add now ones, or delete old ones with in your project directory using your preferred code editor</p>
</li>
<li><p>Stage your changes</p>
</li>
</ul>
</li>
</ul>
<pre><code class="lang-bash">git add . //To add all files to staging
git add specific_file.txt   // To add specific style
</code></pre>
<ul>
<li>Commit your changes</li>
</ul>
<pre><code class="lang-bash">git commit -m <span class="hljs-string">"Initial commit"</span>
</code></pre>
<ul>
<li>Push your changes</li>
</ul>
<pre><code class="lang-bash">git push --set-upstream origin feature/my-new-feature
</code></pre>
<ul>
<li><p>Create a PR</p>
<ul>
<li>Go to remote repository’s website (GitHub or gitlab) and open a pull request to merge your feature branch in to the main branch. This allows team members to review your code before it is integrated</li>
</ul>
</li>
<li><p>Merge the PR</p>
<ul>
<li>After review and approval, merge the pull request via the web interface</li>
</ul>
</li>
<li><p>Update your local main branch</p>
</li>
</ul>
<pre><code class="lang-bash">git checkout main
git pull origin main
</code></pre>
<ul>
<li>This process creates a clear, traceable history of changes and facilities collaboration with in a development team.</li>
</ul>
<p>Git Working Directory → Staging area → repository</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769325738299/42e84a52-8827-4c48-a5dd-9b667d2afbe0.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item></channel></rss>