<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Bancy Njeru</title>
    <description>The latest articles on Forem by Bancy Njeru (@bancy_njeru).</description>
    <link>https://forem.com/bancy_njeru</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1929955%2F94390f3d-c547-4c4a-84c3-a54b003f9248.png</url>
      <title>Forem: Bancy Njeru</title>
      <link>https://forem.com/bancy_njeru</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/bancy_njeru"/>
    <language>en</language>
    <item>
      <title>A Beginner's Guide to Git : Understanding Version Control</title>
      <dc:creator>Bancy Njeru</dc:creator>
      <pubDate>Sun, 18 Jan 2026 10:07:13 +0000</pubDate>
      <link>https://forem.com/bancy_njeru/a-beginners-guide-to-git-understanding-version-control-h97</link>
      <guid>https://forem.com/bancy_njeru/a-beginners-guide-to-git-understanding-version-control-h97</guid>
      <description>&lt;p&gt;When you first hear about &lt;strong&gt;Git&lt;/strong&gt;, it sounds intimidating, but once you understand &lt;em&gt;why&lt;/em&gt; Git exists and how the basic commands work, everything starts to make sense.&lt;/p&gt;

&lt;p&gt;This article will walk you through:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What version control is (in layman’s language)&lt;/li&gt;
&lt;li&gt;How Git tracks changes&lt;/li&gt;
&lt;li&gt;How to &lt;strong&gt;push&lt;/strong&gt; and &lt;strong&gt;pull&lt;/strong&gt; code&lt;/li&gt;
&lt;li&gt;The most common Git commands&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What Is Version Control?
&lt;/h2&gt;

&lt;p&gt;Remember working on assignments and saving your file as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;project_final.docx&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;project_final_v2.docx&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;project_final_really_final.docx&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now imagine doing this with &lt;strong&gt;code&lt;/strong&gt;, across &lt;strong&gt;months or years&lt;/strong&gt;, with &lt;strong&gt;several people&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That’s where &lt;strong&gt;version control&lt;/strong&gt; comes in.&lt;/p&gt;

&lt;h3&gt;
  
  
  Version control helps you:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Track changes over time&lt;/li&gt;
&lt;li&gt;Go back to older versions if something breaks&lt;/li&gt;
&lt;li&gt;Collaborate with others without tampering with each other’s work&lt;/li&gt;
&lt;li&gt;Know &lt;strong&gt;who changed what and when&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Git&lt;/strong&gt; is the most popular version control system.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is Git?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Git&lt;/strong&gt; is a tool that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Runs on your computer&lt;/li&gt;
&lt;li&gt;Tracks changes in your project files&lt;/li&gt;
&lt;li&gt;Lets you save “snapshots” of your work&lt;/li&gt;
&lt;li&gt;Connects your local project to online platforms like &lt;strong&gt;GitHub&lt;/strong&gt; or &lt;strong&gt;GitLab&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Key Git Concepts
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Repository (Repo)
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;repository&lt;/strong&gt; is your project folder that Git is tracking.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Local repository&lt;/strong&gt; → on your computer
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Remote repository&lt;/strong&gt; → online (e.g. GitHub)&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  2. Working Directory
&lt;/h3&gt;

&lt;p&gt;This is where you write and edit your code.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Changes exist here but they are &lt;strong&gt;not saved yet&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  3. Staging
&lt;/h3&gt;

&lt;p&gt;Before saving changes, Git asks:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Which changes do you want to include?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The &lt;strong&gt;staging area&lt;/strong&gt; is where you prepare changes before saving them.&lt;/p&gt;




&lt;h3&gt;
  
  
  4. Commit
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;commit&lt;/strong&gt; is a saved snapshot of your project.&lt;/p&gt;

&lt;p&gt;Each commit:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Has an ID (identifier)&lt;/li&gt;
&lt;li&gt;Has a description of the change&lt;/li&gt;
&lt;li&gt;Can be restored later&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Installing Git
&lt;/h2&gt;

&lt;p&gt;Check if Git is installed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If not:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Linux&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;macOS&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Windows&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Download from &lt;code&gt;https://git-scm.com&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Starting a Git Project
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Initialize Git
&lt;/h3&gt;

&lt;p&gt;Inside your project folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tells Git to start tracking your project.&lt;/p&gt;




&lt;h3&gt;
  
  
  Check Repository Status
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command shows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Modified files&lt;/li&gt;
&lt;li&gt;Staged files&lt;/li&gt;
&lt;li&gt;What Git is waiting for&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Tracking Changes in Git 📝
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Make Changes
&lt;/h3&gt;

&lt;p&gt;Edit or create a file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;project1.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Git detects the change but hasn’t saved it yet.&lt;/p&gt;




&lt;h3&gt;
  
  
  Step 2: Stage Changes
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add project1.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or stage all changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 3: Commit Changes
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Add python file"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This saves a snapshot of your work.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 Tip: Write commit messages as clear explanations for humans.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Understanding Push and Pull 🔄
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Local vs Remote Repositories
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Local&lt;/strong&gt; → your computer&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Remote&lt;/strong&gt; → GitHub / GitLab&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Pushing Code (Upload Your Work)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Push&lt;/strong&gt; sends your commits to the remote repository:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After pushing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your code is online&lt;/li&gt;
&lt;li&gt;Others can access it&lt;/li&gt;
&lt;li&gt;Your work is backed up&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Pulling Code (Download Updates)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Pull&lt;/strong&gt; gets the latest changes from the remote repository:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git pull origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should pull everytime before starting work&lt;/p&gt;




&lt;h2&gt;
  
  
  A Typical Git Workflow 🔁
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git pull
&lt;span class="c"&gt;# make changes&lt;/span&gt;
git status
git add &lt;span class="nb"&gt;.&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Describe what you changed"&lt;/span&gt;
git push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the basic Git loop you'll use daily.&lt;/p&gt;




&lt;h2&gt;
  
  
  Viewing Change History
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This shows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Commit history&lt;/li&gt;
&lt;li&gt;Authors&lt;/li&gt;
&lt;li&gt;Timestamps&lt;/li&gt;
&lt;li&gt;Commit messages&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Final Thoughts 🌱
&lt;/h2&gt;

&lt;p&gt;Git might feel overwhelming at first, but you get a hold of it.&lt;/p&gt;

&lt;p&gt;Focus on these commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git status&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git add&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git commit&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git push&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git pull&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With practice, you'll become a Git Guru.&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀&lt;/p&gt;

</description>
      <category>versioncontrol</category>
      <category>git</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
