<?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>DEV Community: Qudus Olaniyi YUSUFF</title>
    <description>The latest articles on DEV Community by Qudus Olaniyi YUSUFF (@niyhi).</description>
    <link>https://dev.to/niyhi</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%2F3960912%2Fea5b1330-2383-4edf-bf2e-c064ebeec486.png</url>
      <title>DEV Community: Qudus Olaniyi YUSUFF</title>
      <link>https://dev.to/niyhi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/niyhi"/>
    <language>en</language>
    <item>
      <title>A Beginner’s Guide to Git Branching and Merging (Without the Panic)</title>
      <dc:creator>Qudus Olaniyi YUSUFF</dc:creator>
      <pubDate>Sun, 31 May 2026 08:51:14 +0000</pubDate>
      <link>https://dev.to/niyhi/a-beginners-guide-to-git-branching-and-merging-without-the-panic-2f07</link>
      <guid>https://dev.to/niyhi/a-beginners-guide-to-git-branching-and-merging-without-the-panic-2f07</guid>
      <description>&lt;p&gt;Imagine you are working on a new feature for your web app. You write some code, but everything breaks, and suddenly your whole project is ruined. This is why Git branches exist. They allow you to test new ideas in a safe sandbox without touching your main, working code. By using the terminal, you gain complete control over your project history and collaborate like a professional developer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites: Setting the Stage
&lt;/h2&gt;

&lt;p&gt;Before you can practice branching, you need a live Git repository with at least one save point (commit). Git cannot track or display branches in an empty repository. &lt;/p&gt;

&lt;p&gt;Open your terminal, create a project folder, initialize Git, and create your foundational commit by running these commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;git-blog-post &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;git-blog-post
git init
git branch &lt;span class="nt"&gt;-m&lt;/span&gt; main
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Base project structure"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; README.md
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;"Initial commit"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that your repository has a history, you are ready to manage your branches.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Check Your Current Branch
&lt;/h2&gt;

&lt;p&gt;Before changing anything, you must find out exactly where you are standing in your repository. Run the following command:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;This command lists all local branches. The branch with an asterisk (&lt;code&gt;*&lt;/code&gt;) next to it is your active branch.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnavdxffsw5teiwxslqjm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnavdxffsw5teiwxslqjm.png" alt="Terminal output showing the active local branch marked with an asterisk" width="800" height="292"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Create and Switch to a New Branch
&lt;/h2&gt;

&lt;p&gt;To experiment safely, create an isolated workspace. Run this command to create a new branch named &lt;code&gt;feature-test&lt;/code&gt; and switch to it immediately:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout &lt;span class="nt"&gt;-b&lt;/span&gt; feature-test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using the &lt;code&gt;-b&lt;/code&gt; flag is a handy shortcut. Without it, you would have to run two separate commands: &lt;code&gt;git branch feature-test&lt;/code&gt; to create it, and then &lt;code&gt;git checkout feature-test&lt;/code&gt; to switch over. This flag combines them into a single step, saving you precious terminal keystrokes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F69e9ure1k4j3ktmn6n3u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F69e9ure1k4j3ktmn6n3u.png" alt="Terminal output confirming a successful switch to the new feature-test branch" width="800" height="319"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Make and Commit Your Changes
&lt;/h2&gt;

&lt;p&gt;Now, create a simple file to simulate working on a new feature. Run the following command to create a new file named &lt;code&gt;sample.txt&lt;/code&gt; with some placeholder text:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"This is a new feature test."&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; sample.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, stage the file to prepare it for saving:&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 sample.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, permanently save this snapshot to your branch history with a descriptive commit message:&lt;br&gt;
&lt;/p&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;"Testing a new feature"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6z4idxouhs4m0tlgx6yw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6z4idxouhs4m0tlgx6yw.png" alt="Terminal output showing the file being created, staged, and successfully committed" width="800" height="319"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Merge the Changes Back to Main
&lt;/h2&gt;

&lt;p&gt;Your feature works perfectly, so it is time to bring it into your main project. First, navigate back to your primary branch:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Now, pull the work you did on &lt;code&gt;feature-test&lt;/code&gt; into your &lt;code&gt;main&lt;/code&gt; branch:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;This performs a "fast-forward" merge, cleanly moving your &lt;code&gt;main&lt;/code&gt; branch pointer up to match the latest commit you made in your feature sandbox.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjs6fl8fbintcy85yahhs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjs6fl8fbintcy85yahhs.png" alt="Terminal output showing a successful fast-forward merge into the main branch" width="800" height="319"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Mastering branching is the first real step to working like a professional engineer. Now you can experiment with confidence, knowing your main code is always safe.&lt;/p&gt;

</description>
      <category>git</category>
      <category>devops</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
