<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Devinda wanasinghe on Medium]]></title>
        <description><![CDATA[Stories by Devinda wanasinghe on Medium]]></description>
        <link>https://medium.com/@devindawanasinghe?source=rss-3fd8f4c492ee------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kZmyBwd5BUrDM9HZS1Xdqg.jpeg</url>
            <title>Stories by Devinda wanasinghe on Medium</title>
            <link>https://medium.com/@devindawanasinghe?source=rss-3fd8f4c492ee------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 04:39:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@devindawanasinghe/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Git for Professionals -Part 1]]></title>
            <link>https://medium.com/@devindawanasinghe/git-for-professionals-part-1-04a944c3f7f2?source=rss-3fd8f4c492ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/04a944c3f7f2</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[version-control]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Devinda wanasinghe]]></dc:creator>
            <pubDate>Thu, 25 Dec 2025 13:32:21 GMT</pubDate>
            <atom:updated>2025-12-25T13:32:21.844Z</atom:updated>
            <content:encoded><![CDATA[<h4>A Complete Guide for Undergraduates Entering the IT Industry</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IQ9fhkRJa4EabDZjp-d0Jg.png" /></figure><p>Welcome to your Git journey! If you’re getting ready to enter the <strong>IT industry</strong>, there is one skill you really should not miss. It is <strong>Version Controlling</strong>, or the most widely used tool in the industry right now, <strong>Git</strong>.</p><p>Don’t worry! It’s not scary or complicated!<br>Git is a tool that developers use every day to track changes, work as a team, and keep projects secure. From small startups to large tech companies,<strong> Git is everywhere.</strong></p><blockquote>This is not just another tutorial… This is a <strong><em>level-based</em></strong> adventure that will transform you from a <strong>C<em>omplete</em></strong><em> </em><strong><em>beginner to a Git professional</em></strong>. <br>Each level builds on the previous one, and as you progress, you will unlock the skills that every IT professional needs.<em> 💪🏼</em></blockquote><h3>What is Git and Why Does It Matter ?</h3><h4><strong>The Problem Git Solves</strong></h4><p>Imagine you are writing code for a project. You make changes, something breaks, and you wish you could go back to the version that worked. Or you are working with teammates, and everyone’s changes are overwriting each other’s work.<em> Chaos, right?</em></p><p><strong>Git is version control software</strong> that tracks every change to your code, who made it, and when. <br>Think of it as a time machine for your code combined with a collaboration superpower.💡</p><h4>Git vs GitHub: Clearing the Confusion</h4><ul><li><strong>Git</strong>: The version control system (software on your computer)</li><li><strong>GitHub</strong>: A website that hosts Git repositories online (like Google Drive for code)</li><li><strong>GitLab, Bitbucket</strong>: Alternatives to GitHub</li></ul><p>You use Git locally, then push your code to platforms like GitHub to share with others.</p><h4><strong>Ready to begin? Let’s start at Level 0. 🤝</strong></h4><h3>🔸LEVEL 0: Getting Started: Installation and Setup</h3><p><strong>Installing Git<br></strong>Windows:</p><pre>Download from git-scm.com and run the installer</pre><p><strong>Mac:</strong></p><pre>brew install git</pre><p><strong>Linux:</strong></p><pre>sudo apt-get install git  # Ubuntu/Debian<br>sudo yum install git      # CentOS/Fedora</pre><h4>First Time Configuration</h4><p>After installing, set up your identity.</p><pre>git config --global user.name &quot;Your Name&quot;<br>git config --global user.email &quot;your.email@example.com&quot;</pre><p>These details will be attached to every change you make.</p><h4>▪ Understanding Git’s Mental Model</h4><p><strong>The Three States<br></strong>Your files can be in 03 states,</p><ol><li><strong>Working Directory</strong>: Where you edit files</li><li><strong>Staging Area (Index)</strong>: Where you prepare files for commit</li><li><strong>Repository (.git directory)</strong>: Where Git permanently stores versions</li></ol><p><em>Think of it like preparing a package:</em></p><ul><li><strong>Working Directory</strong><em>: Items scattered on your desk</em></li><li><strong>Staging Area</strong><em>: Items you have placed in the box</em></li><li><strong>Repository</strong><em>: The sealed package in storage</em></li></ul><blockquote><strong><em>🎉 Level 0 Complete! </em></strong>You have installed Git and configured it. Time to make your first commit.</blockquote><h3>🔸LEVEL 1: Creating Your First Repository</h3><p><strong>Starting a new project.</strong></p><pre>mkdir my-project<br>cd my-project<br>git init</pre><p>This creates a hidden .git folder where Git stores all its data.</p><h4>🔹Real Scenario<strong>: Your First Commit</strong></h4><pre># Create a file (example)<br>echo &quot;# My First Project&quot; &gt; README.md</pre><pre># Check status<br>git status<br><br># Add to staging area<br>git add .<br><br># Commit with a message<br>git commit -m &quot;Add README file&quot;</pre><p><strong>What just happened?</strong></p><ul><li>git status: Shows which files changed</li><li>git add .: Moves files to staging area</li><li>git commit: Saves a snapshot with a message</li></ul><blockquote><strong><em>🎉 LEVEL 1 COMPLETE!</em></strong></blockquote><blockquote><strong>Achievement Unlocked:</strong> <em>First Commit Master</em></blockquote><p><strong><em>“The secret to getting ahead is getting started.”</em></strong> (<em>Mark Twain)</em></p><blockquote>You have just made your first commits! You can now save your work with Git. Most people give up before getting here - but not you. Take a moment to celebrate, then let’s level up! 🎊</blockquote><h3>🔸LEVEL 2: The Daily Workflow</h3><p><strong>Typical development cycle:</strong></p><pre># 1. Check what changed<br>git status</pre><pre># 2. See specific changes<br>git diff<br><br># 3. Add files to staging<br>git add filename.js<br><br># Or add all changes<br>git add .<br><br># 4. Commit with descriptive message<br>git commit -m &quot;Add user login feature&quot;<br><br># 5. View commit history<br>git log</pre><h4>🔹Real Scenario:</h4><p>Let’s say you’re building a calculator app,</p><pre>git add calculator.js<br><br>git commit -m &quot;Add addition function&quot;<br></pre><pre># Add again more functionality (example)<br>echo &quot;function subtract(a, b) { return a - b; }&quot; &gt;&gt; calculator.js</pre><pre>git add calculator.js<br><br>git commit -m &quot;Add subtraction function&quot;<br><br># View your progress<br>git log --oneline</pre><p>Output:</p><pre>b4f21a3 Add subtraction function<br>8c92d5e Add addition function</pre><blockquote><strong><em>🎉 LEVEL 2 COMPLETE!</em></strong></blockquote><blockquote><strong>Achievement Unlocked: </strong><em>Daily Workflow Warrior</em></blockquote><p><strong>“Success is the sum of small efforts repeated day in and day out.” </strong><em>(Robert Collier)</em></p><blockquote>You now know the daily rhythm of professional developers! You can track changes, see differences, and build up a meaningful history. You’re no longer a beginner — you’re becoming a practitioner. Onward! 💪</blockquote><h3>🔸LEVEL 3: Connecting to the World</h3><p>Time to take your code online and collaborate with others!</p><h4>🔹Mission: Push to GitHub</h4><p>First, create a repository on GitHub.com, then:</p><pre># Link your local repo to GitHub<br>git remote add origin https://github.com/yourusername/my-first-project.git</pre><pre># Upload your code<br>git push -u origin main<br><br># FINISHED</pre><pre># From now on, just use:<br>git push</pre><h4>The Pull-Push Dance</h4><pre># Morning routine: Get latest changes<br>git pull</pre><pre># Do your work...<br>git add .<br><br>git commit -m &quot;Implement new feature&quot;<br><br># Share your work<br>git push<br><br># Before leaving: Get updates from teammates<br>git pull</pre><h4>🔹Real Scenario: Working with a Team</h4><pre># Your teammate Rohan pushed changes overnight<br>git pull origin main<br><br># You see: &quot;calculator.py&quot; was updated<br># Now you have him changes!d</pre><pre># Now You add your features (example)<br><br>echo &quot;def multiply(a, b):&quot; &gt;&gt; calculator.py<br>echo &quot;    return a * b&quot; &gt;&gt; calculator.py</pre><pre>git add calculator.py<br><br>git commit -m &quot;Add multiplication function&quot;<br><br>git push<br># Rohan will get your changes when he does git pull!</pre><h4>🔹Cloning: Joining Existing Projects</h4><pre># First day at your internship<br>git clone https://github.com/company/project.git</pre><pre># You now have the entire project with full history!<br>cd project<br>git log     # See what everyone has been working on</pre><p>Later, like the <strong>Real Scenario </strong>we talked about above, the steps can forward…</p><blockquote><strong><em>🎉 LEVEL 3 COMPLETE!</em></strong></blockquote><blockquote><strong>Achievement Unlocked:</strong> <em>Cloud Connector</em></blockquote><p><strong><em>“Alone we can do so little; together we can do so much.” (</em></strong><em>Helen Keller)</em></p><blockquote>Your code now lives in the cloud! You can collaborate with developers worldwide, contribute to open source, and showcase your portfolio. You’ve just unlocked the social aspect of coding. This is where the real magic begins! ✨</blockquote><h3>🔸LEVEL 4: Branching - The Superpower</h3><p>This is where Git transforms from useful to absolutely magical. <br>Branches let you work on multiple features simultaneously without chaos.</p><h4>The Mental Model</h4><p>Think of branches as parallel universes:</p><ul><li><strong>main branch</strong>: The stable, production-ready universe</li><li><strong>feature branches</strong>: Experimental universes where you try new things</li><li><strong>Merging</strong>: Bringing successful experiments back to the main universe</li></ul><h4>🔹Mission: Your First Branch</h4><pre># Create and switch to a new branch<br>git checkout -b example-branch</pre><pre># Check where you are<br>git branch<br><br># * example-branch  (the * shows current branch)<br>#   main</pre><pre># Make changes (example)<br>echo &quot;Hello World!&quot; &gt; example.txt<br>echo &quot;    #SRI LANKA&quot; &gt;&gt; example.txt</pre><pre>git add example.txt # Use to only add example.txt file<br># OR<br>git add . # Use add all changes<br><br>git commit -m &quot;Your Commit Message&quot;</pre><pre># Get latest updates from main branch (important!)<br>git pull origin main</pre><pre># &lt;example.txt&gt; file doesn&#39;t exist in main branch! It&#39;s only have in the your example-branch branch<br><br># Push your example-branch to GitHub<br>git push origin example-branch<br><br># Now &lt;example.txt&gt; file exists in GitHub on example-branch</pre><h4><strong>🔹Next steps on GitHub:</strong></h4><ol><li>Go to your repository on GitHub</li><li>Click “Create Pull Request”</li><li>Select: example-branch → main</li><li>Add description of what you built</li><li>Request review from teammates</li><li>After approval, click “<strong>Merge Pull Request</strong>”</li><li>Your feature is now in main!</li></ol><h4><strong>🔹Clean up locally:</strong></h4><pre># Switch back to main<br>git checkout main</pre><pre># Get the merged code<br>git pull origin main<br><br># example.txt now exists in main too!</pre><h3>🔹Handling Your First Merge Conflict</h3><h4>Wait! What If Things Go Wrong ?⚠️</h4><p>So far, everything has been smooth sailing. <br> - You created your branch, <br> - made changes, <br> - pulled updates, <br> - pushed your code, and merged via Pull Request. <strong>Perfect, right</strong>?</p><p><strong>But here’s the reality check:<br></strong>Imagine this scenario:</p><p>🧑‍💻 <strong>You</strong> are working on example.txt, adding a two sentences.</p><p>👩‍💻 <strong>Your teammate Rohan</strong> is ALSO working on example.txt, adding a another paragraph.</p><p><strong>What happens ?</strong></p><ol><li>Rohan finishes first and merges her changes to main</li><li>You finish and try to git pull origin main</li><li><strong>💥 BOOM! CONFLICT!</strong></li></ol><p><strong>Git is confused</strong>: <em>“Wait, both of you changed the same file! Which version should I keep?”</em></p><h4>🔹When Do Conflicts Happen?</h4><p>Conflicts occur in <strong>two situations</strong>:</p><p><strong>Situation 1: When you pull updates</strong></p><pre>git pull origin main<br># CONFLICT (content): Merge conflict in auth.py</pre><p><strong>Situation 2: </strong>When creating a Pull Request</p><pre>GitHub shows: &quot;This branch has conflicts that must be resolved&quot;</pre><h4>🔹Why Does This Happen?</h4><p>Think of it like two people editing the same Google Doc simultaneously:</p><ul><li>You write “The sky is blue” on line 5</li><li>Rohan writes “The sky is green” on line 5</li><li>Google Doc gets confused: “Which is correct?”</li></ul><p><em>Git faces the same dilemma. It can automatically merge changes to </em><strong><em>different parts</em></strong><em> of a file, but when you both edit the </em><strong><em>same lines</em></strong><em>, it needs YOUR help to decide.</em></p><h4>The Good News</h4><p><strong>Conflicts are NORMAL and EASY to fix!</strong> Every developer deals with them daily. Think of them as puzzles, not problems.</p><p>Let’s learn how to solve them like a pro! 👇</p><pre>git merge example-branch</pre><pre># CONFLICT in example.txt<br># Auto-merging failed<br># Open example.txt, you&#39;ll see:<br><br>&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD<br>price = 99.99<br>=======<br>price = 89.99<br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; example-branch</pre><pre># Edit to keep what you want:<br>price = 89.99</pre><pre># Then:<br>git add example.txt<br>git commit -m &quot;Resolve pricing conflict&quot;</pre><pre># Now you can push<br>git push origin example-branch</pre><blockquote><strong><em>🎉 LEVEL 4 COMPLETE!</em></strong></blockquote><blockquote><strong>Achievement Unlocked:</strong> <em>Branch Master</em></blockquote><p><strong><em>“The best way to predict the future is to create it.” (</em></strong><em>Peter Drucker)</em></p><blockquote>You can now work on multiple features simultaneously, experiment without fear, and merge work seamlessly. This is the skill that separates hobbyists from professionals. You’re officially dangerous (in a good way)! 🔥</blockquote><h3>🔸LEVEL 5: Undoing Mistakes &amp; Emergency Fixes — Intermediate Level</h3><p>Even pros make mistakes. This level teaches you how to undo almost anything.</p><h4>🔹Mission: Undo Operations</h4><p><strong>Scenario 1: Undo uncommitted changes</strong></p><p>▪️This discards changes you made but haven’t committed yet.<br><strong>▪️Why use it?</strong> When you break something while coding and just want to go back to the last working version, instead of manually fixing it.</p><pre># You messed up index.html<br>git checkout -- index.html<br># File restored to last commit!</pre><pre># Undo ALL uncommitted changes<br>git reset --hard</pre><p><strong>Scenario 2: Undo last commit (keep changes)</strong></p><p>▪️This removes your last commit but keeps all your code changes intact.<br><strong>▪️Why use it?</strong> When you realize your commit message was unclear or you forgot to add some files to that commit.<br><strong>▪️Think of it like:</strong> Taking a sealed envelope, opening it, keeping the letter inside, and preparing to seal it again with a better label.</p><pre>git reset --soft HEAD~1<br># Commit undone, files still edited<br># You can now re-commit with different message</pre><p><strong>Scenario 3: Undo last commit (discard everything)</strong></p><p>▪️This removes your last commit and permanently deletes all the changes you made in it.<br><strong>▪️Why use it?</strong> When you committed something completely wrong or experimental code that you don’t want anymore.</p><pre>git reset --hard HEAD~1<br># Commit gone, changes gone<br># Use with caution!</pre><p><strong>Scenario 4: Undo a commit safely (for pushed commits)</strong></p><p>▪️This undoes a previous commit by creating a new commit that does the opposite changes.<br><strong>▪️Why use it?</strong> When you need to undo something you already pushed to GitHub and others might have already pulled.<br><strong>▪️Think of it like:</strong> Writing “VOID” on a check instead of tearing it up,<br>It leaves a clear record that you canceled it, rather than pretending it never existed.</p><pre>git revert abc123<br># Creates a NEW commit that undoes abc123<br># Safe for shared branches</pre><p><strong>▪️</strong>abc123<strong> </strong>is a <strong>COMMIT HASH</strong> (commit ID)<br>▪️Every commit you make gets a <strong>unique ID</strong> (like a fingerprint). It looks like: a3f5b2c or abc123def456 <br>▪️You can see <strong>Commit Hash</strong> using this command: git log --online</p><h4>🔹The Stash Operation: Your Temporary Shelf</h4><p>▪️Temporarily saves your uncommitted changes in a “safe place” so you can work on something else, then brings them back later.<br><strong>▪️Why use it?</strong> When you’re in the middle of coding a feature but need to quickly switch to fix an urgent bug without committing half finished work.</p><pre># You&#39;re working on a feature, boss needs urgent bugfix<br>git stash<br># Your changes are safely stored away</pre><pre>git checkout main<br># Fix the bug...<br><br>git add .<br><br>git commit -m &quot;Fix critical bug&quot;<br><br># Back to your feature<br>git checkout feature-branch<br><br>git stash pop<br># Your work is back!</pre><h4>🔹Viewing History Like a Pro</h4><p><strong>Scenario 1:<br></strong>▪️Displays your entire commit history in a visual, easy to read format with branch lines.<br><strong>▪️Why use it?</strong> To understand your project’s timeline and see how different branches evolved.</p><pre># Beautiful graph view<br>git log --oneline --graph --all --decorate</pre><p><strong>Scenario 2:</strong><br>▪️Shows who last modified each line in a file, with the commit and date.<br><strong>▪️Why use it?</strong> To find out who wrote a specific piece of code, so you can ask them questions or understand why they wrote it that way.</p><pre># See who changed what<br>git blame filename.js</pre><p><strong>Scenario 3:</strong><br>▪️Git helps you find exactly which commit introduced a bug by automatically testing different versions.<br><strong>▪️The Problem:</strong> Your app is broken NOW, but it was working fine 2 weeks ago. Between then and now, you made 100 commits. Which commit broke it? 😱</p><p><strong>▪️Without git bisect:</strong> You’d check all 100 commits one by one… that’s horrible!<br><strong>▪️With git bisect:</strong> Git does a <strong>smart search</strong> and finds the bad commit in just 7 tries! (like a guessing game)</p><p><strong>Your commit history:</strong></p><pre>a1b2c3 (today) ← YOU ARE HERE - Bug exists! 😞<br>d4e5f6 (yesterday)<br>g7h8i9 (3 days ago)<br>j1k2l3 (1 week ago)<br>m4n5o6 (2 weeks ago) ← This was working! ✔️</pre><p><strong>Step 1: Start the search</strong></p><pre># Find when a bug was introduced<br>git bisect start</pre><p><em>“Hey Git, help me find the bad commit!”</em></p><p><strong>Step 2: Mark the current version as BAD</strong></p><pre>git bisect bad   # Current version has bug</pre><p><em>“The code I’m on RIGHT NOW has the bug”</em></p><p><strong>Step 3: Mark an old working version as GOOD</strong></p><pre>git bisect good m4n5o6    # This commit was good</pre><p><em>“But 2 weeks ago at commit m4n5o6, everything worked fine!”</em></p><p><strong>What Git does now:</strong></p><p>Git thinks: <strong><em>“Okay, the bug appeared somewhere between m4n5o6 (good) and a1b2c3 (bad). Let me check the MIDDLE commit!”</em></strong></p><h4>🔹Real Scenario: Fixing Mistakes with Git Amend</h4><p><strong>Example:<br>The Problem:</strong> It’s Friday evening, you’re about to leave office. You just committed a file with <strong>passwords and database credentials</strong> to Git. If you push this to GitHub, EVERYONE can see your passwords! 😱</p><pre># Friday 4:55 PM - You accidentally committed passwords<br>git log --oneline<br><br># ab12cd3 Add config with DB credentials  &lt;- OH NO!</pre><pre># Remove the file <br>git rm --cached config.env<br><br># Add to .gitignore<br>echo &quot;config.env&quot; &gt;&gt; .gitignore<br><br>git add .gitignore<br><br># This replaces the last commit<br>git commit --amend -m &quot;Add login feature and gitignore&quot;<br><br># Old commit with passwords is GONE!<br># New commit has .gitignore instead<br><br># Now you can safely push to GitHub<br>git push<br><br># Crisis averted!</pre><p>▪️git rm = remove from Git<br>▪️--cached = only remove from Git tracking, NOT from your computer<br>▪️git commit --amend = <strong>&quot;Undo and redo the last commit&quot;</strong></p><p>It’s like:</p><ol><li>Opening a sealed envelope (last commit)</li><li>Removing the embarrassing photo (config.env)</li><li>Adding a note to never include photos (.gitignore)</li><li>Sealing it again (new commit)</li></ol><h4>🔹The Difference Git Revert vs Git Amend</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*9T5rXFGoZbxi4covIWogFw.png" /></figure><blockquote>🎉<strong><em> LEVEL 5 COMPLETE!</em></strong></blockquote><blockquote><strong>Achievement Unlocked:</strong> <em>Rescue Master</em></blockquote><p><strong><em>“Mistakes are the portals of discovery.” (</em></strong><em>James Joyce)</em></p><blockquote>You can now undo mistakes, travel through history, and recover from disasters. You have the confidence to experiment boldly, knowing you can always go back. This is freedom! 🦸‍♂️</blockquote><h3>🏆 Part 1 Complete: You’re Now a Git Intermediate!</h3><h3>🎊 Congratulations! Look How Far You’ve Come!</h3><p><strong>Level 0:</strong> Installed Git and learned what version control is<br> <strong>Level 1:</strong> Made your first commits and understood the three zones<br> <strong>Level 2:</strong> Mastered the daily workflow every developer uses<br> <strong>Level 3:</strong> Connected to GitHub and started collaborating<br> <strong>Level 4:</strong> Unlocked branching superpowers and handled merge conflicts<br> <strong>Level 5:</strong> Learned to undo mistakes and rescue any situation</p><p>You’ve gone from complete beginner to <strong>confident Git user</strong> in just 5 levels!</p><h3>💪 What You Can Do Now:</h3><p>▪️Track and manage your code history<br>▪️Work on multiple features simultaneously with branches<br>▪️Collaborate with teammates on GitHub<br>▪️Handle merge conflicts like a pro<br>▪️Undo any mistake safely<br>▪️Rescue yourself from disasters</p><p><strong>You’re no longer a beginner — you’re a practitioner!</strong> <br>These skills alone are enough to get you through most real world development scenarios.</p><h3>🎓 Quick Reference [Your Level 0–5 Cheat Sheet]</h3><pre># Setup<br>git config --global user.name &quot;Name&quot;<br>git config --global user.email &quot;email&quot;<br><br><br># Daily Workflow<br>git status               # Check status<br>git add &lt;file&gt;           # Stage changes<br>git commit -m &quot;msg&quot;      # Commit changes<br>git push                 # Upload to GitHub<br>git pull                 # Download updates<br><br><br># Branching<br>git checkout -b &lt;name&gt;   # Create branch<br>git branch               # List branches<br>git merge &lt;branch&gt;       # Merge branch<br>git branch -d &lt;name&gt;     # Delete branch<br><br><br># Rescue Operations<br>git checkout -- &lt;file&gt;   # Undo file changes<br>git reset --soft HEAD~1  # Undo last commit (keep changes)<br>git reset --hard HEAD~1  # Undo last commit (discard all)<br>git revert &lt;commit&gt;      # Safely undo old commit<br>git stash / git stash pop # Temporary storage<br><br><br># History<br>git log --oneline        # View commit history<br>git diff                 # See changes</pre><h3>See You in Part 2!</h3><p>When you’re ready to become a <strong>Git Master</strong> and learn the advanced techniques that senior developers use, continue to:</p><h3>[Part 2: Git Mastery — Levels 6, 7 &amp; Final Boss]</h3><p><strong>Coming Soon…</strong></p><p>Until then, keep practicing, keep committing, and remember: <strong>every expert was once a beginner who didn’t give up.</strong></p><p>Found this helpful?</p><blockquote>💾 <strong>Save</strong><em> this guide — you’ll need it again!</em><br>💬 <strong>Comment </strong><em>which level you found most challenging</em><br>🔄 <strong>Share</strong> <em>with your coding friends who need this</em><br>➕ <strong>Follow</strong> <em>for Part 2 + more developer guides</em></blockquote><p><strong>Connect With Me…<br>▪️LinkedIn: [</strong><a href="https://www.linkedin.com/in/devinda-wanasinghe-51433631a/"><strong>linkedin.com/in/devindawanasinghe</strong></a><strong>]</strong><br><em>Let’s connect! I share daily tips on software development and career growth.</em></p><p><strong>▪️GitHub: [</strong><a href="https://github.com/DevindaWanasinghe"><strong>github.com/DevindaWanasinghe</strong></a><strong>]</strong><br><em>Check out my projects and feel free to collaborate!</em></p><p>Your support helps me create more free content like this! 🤝<br><em>Written with ❤️ for aspiring developers entering the IT industry</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=04a944c3f7f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking SELinux: Security Without the Confusion.]]></title>
            <link>https://medium.com/@devindawanasinghe/unlocking-selinux-security-without-the-confusion-14c6ca927829?source=rss-3fd8f4c492ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/14c6ca927829</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[selinux]]></category>
            <category><![CDATA[linux-security]]></category>
            <category><![CDATA[server-administration]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Devinda wanasinghe]]></dc:creator>
            <pubDate>Sat, 15 Nov 2025 10:25:06 GMT</pubDate>
            <atom:updated>2025-11-15T10:25:06.857Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mNJKKiy8b4Mb6RBqcDzSXA.png" /></figure><h3>🔸What Is SELinux?</h3><p><strong>SELinux (Security-Enhanced Linux)</strong> is a powerful security system built into Linux.<br>Think of it like a <strong>security guard</strong> 🛡️ at the gate of your server.</p><p>Linux is known for its stability and security. But as systems grow, basic file permissions are not enough to protect servers from modern cyber threats.</p><p><strong>SELinux (Security-Enhanced Linux)</strong> adds an extra, smarter layer of protection that helps keep systems safe from both mistakes and attacks.</p><p>It controls: <br>◾Which program can access which file<br>◾What actions are allowed<br>◾How processes communicate</p><p>In simple words:<br>◾<strong>Normal Linux permissions = door lock</strong><br>◾<strong>SELinux = door lock + CCTV + guard checking your ID</strong></p><p>So SELinux adds <strong>extra protection</strong> beyond normal file permissions.</p><h3>🔸SELinux Modes (3 Modes You Must Know)</h3><h4>1. Enforcing (Most secure)</h4><p>SELinux checks <em>and blocks</em> anything not allowed.<br>◾Best for production environments<br>◾Harder to troubleshoot<br>◾Very strict</p><h4>2. Permissive (Learning mode)</h4><p>SELinux checks things but <strong>does NOT block</strong>.<br>◾Only logs warnings<br>◾Good for troubleshooting</p><h4>3. Disabled (Turned off)</h4><p>SELinux is completely turned off.<br>◾No checks<br>◾No logs<br>◾Less secure but simple</p><h3>🔸Situations That Call for SELinux</h3><p>You should use SELinux when you need <strong>strong, fine-grained security</strong>, such as:</p><h4>1. Securing Web Servers</h4><p><em>Example</em>: Apache or Nginx needs to serve files safely.<br>SELinux prevents attackers from making the web server access system files.</p><h4>2. Protecting Databases</h4><p>It blocks unknown programs from reading sensitive DB files.</p><h4>3. Running Enterprise Systems</h4><p>Banks, government, hospitals, and universities use SELinux because<br> they cannot risk data leaks.</p><h4>4. Multi-User or Multi-App Servers</h4><p>When many apps run on the same machine, SELinux ensures <br>one app cannot peek into another’s data.</p><h4>5. Preventing Zero-Day Attacks</h4><p>Even if a hacker breaks into an application, <br>SELinux can stop them from moving further.</p><h3>🔸Why Modern Systems Depend on SELinux</h3><h4>1. Because normal permissions are not enough</h4><p>◾If a program is hacked, normal Linux permissions can fail.<br>◾SELinux adds a second layer of defense.</p><h4>2. Because modern servers face advanced attacks</h4><p>◾Cyberattacks today are smarter.<br>◾SELinux stops things even root user sometimes can’t.</p><h4>3. Because it prevents “accidental damage”</h4><p>◾If a misconfigured app tries to access wrong files,<br>◾SELinux blocks it and logs a warning.</p><h4>4. Because organizations require security compliance</h4><p>◾Many industries (finance, telecom, gov) require SELinux enabled<br> to pass security audits.</p><h3>🔸Why Are SELinux Packages Installed by Default?</h3><p>Because modern Linux systems (CentOS/RHEL) prioritize <strong>security</strong>.<br>So they install SELinux packages automatically to keep your system safe.</p><p><em>Example: Think of it like a car having airbags installed </em><strong><em>even if you switch them off</em></strong><em>.</em> 🚗💨 <em>They are there if you need them.</em></p><h3>🔸Why Do Some Teams Disable SELinux? (Very Common Reason)</h3><p>Many DevOps teams <strong>temporarily disable SELinux</strong> during:<br>◾Testing applications<br>◾Running containers<br>◾Deploying new tools<br>◾Avoiding unexpected blocking</p><p><strong>Reason:</strong> SELinux can block services quietly, causing errors that beginners find confusing.</p><p><em>Example:</em><br>◾<em>Website works locally but fails on server</em><br>◾<em>Database connection blocked</em><br>◾<em>Logs show “permission denied” even though permissions look correct</em></p><p><strong>SELinux was the reason… </strong>silently sitting in the background. 😅</p><p>So teams often do:<br>◾<strong>Disable SELinux temporarily to avoid interruptions<br></strong>◾<strong>Re-enable later when configurations are ready</strong></p><h3>🔸How to Use SELinux (Simple Steps &amp; Real Example)</h3><p>SELinux has <strong>three modes, </strong>as we discussed above:<br>1. <strong>Enforcing — </strong>Blocks actions<br>2. <strong>Permissive</strong> — Allows but logs warnings<br>3. <strong>Disabled</strong> — SELinux is off</p><p>◾Check current mode:</p><pre>getenforce</pre><p>◾Change temporary mode (no reboot):</p><pre>sudo setenforce 0    # permissive<br>sudo setenforce 1    # enforcing</pre><p>◾Change permanent mode:</p><p>Edit:</p><pre>/etc/selinux/config</pre><p>Set:</p><pre>SELINUX=enforcing   or   permissive   or   disabled</pre><p>Requires reboot.</p><h3>🔸Real-World Problem &amp; How SELinux Solves It</h3><h4>Scenario: Your Apache website cannot load images</h4><p>You upload images to /var/www/myapp/images/,<br><em> but the browser shows:</em></p><blockquote><em>403 Forbidden<br> File not accessible</em></blockquote><p>You check:<br>◾File permissions → correct<br>◾Ownership → correct<br><strong> Still not working.</strong><br> You think “<em>Why is Linux doing this to me?</em>” 😅</p><h4>✔ Root cause</h4><p>SELinux is blocking Apache from reading the new folder.</p><p><strong><em>Solution:<br></em></strong>Allow Apache to read that directory:</p><pre>sudo chcon -t httpd_sys_content_t /var/www/myapp/images/ -R</pre><p>◾Now images load perfectly. 🎉<br>◾<strong>SELinux protected your server from unexpected file access.</strong></p><p><em>Finally….</em></p><p><strong>Every Linux server has two stories:</strong><br> 👨🏼‍💻<strong>One with SELinux turned off…</strong> simple, but vulnerable.<br>👨🏼‍💻 <strong>And one with SELinux turned on…</strong> smarter, safer, and ready for the modern world.</p><blockquote>As you move forward in your Linux and DevOps journey, SELinux will become one of your most trusted tools .🛡️<br> Learn it today — protect your systems tomorrow 🚀</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14c6ca927829" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Zero to React Hero, A Simple Guide to Building Websites]]></title>
            <link>https://medium.com/@devindawanasinghe/from-zero-to-react-hero-a-simple-guide-to-building-websites-b8651e93179c?source=rss-3fd8f4c492ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8651e93179c</guid>
            <dc:creator><![CDATA[Devinda wanasinghe]]></dc:creator>
            <pubDate>Wed, 13 Nov 2024 18:13:00 GMT</pubDate>
            <atom:updated>2024-11-13T18:13:00.971Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ppNV2hRovdTWQ63DyoCwYg.png" /></figure><p><strong>React</strong> is a powerful tool used to make websites interactive and fun. you have sometimes seen websites that react when you click buttons, scroll down, or fill out forms. So….</p><h4>React helps make that happen! Now let’s explore a look at the <strong>13 most important things</strong> you should know about <strong>React</strong>.</h4><h4>1.JSX (JavaScript XML)</h4><p>JSX is a way to write HTML-like code inside JavaScript. it makes writing React code easier and more familiar if you know HTML.</p><pre>const greeting = &#39;Hello&#39;;<br><br>function Welcome(){<br>  return &lt;h1&gt;{greeting}, World!&lt;/h1&gt;; <br>}<br><br>const root = ReactDOM.createRoot(document.getElementById(&#39;root&#39;));<br>root.render(&lt;Welcome/&gt;);</pre><p><em>This code defines a React component named </em><em>welcome that returns a heading saying &quot;Hello, World!&quot; and then renders it into the webpage at the element with the ID </em><em>root.</em></p><h4>2.Components</h4><p>Components are the building blocks of React. They are like small pieces that you can put together to create a full webpage. Components can be reused in many places.</p><pre>function Welcome() {<br>  return &lt;h1&gt;Hello, everyone!&lt;/h1&gt;;<br>}<br><br>export default Welcome;</pre><p><em>This defines a functional component named </em><em>Welcome that returns an </em><em>&lt;h1&gt; element with the text &quot;Hello, everyone!&quot;.</em></p><pre>import Welcome from &#39;./Welcome.js&#39;;<br><br>function App() {<br>  return &lt;Welcome/&gt;;<br>}<br><br>export default App;</pre><p><em>This defines another functional component named </em><em>App, which renders the </em><em>Welcome component.</em></p><h4>3.<strong>Props</strong></h4><p>Props are like packages of information you pass from one component to another. They help make components flexible and able to display different information.</p><pre>import React from &#39;react&#39;;<br><br>function Developer(props){<br>  return &lt;h1&gt; I am a {props.name} &lt;/h1&gt;;<br>}<br><br>export default Developer;</pre><p><em>This file defines the </em><em>Developer component, which takes </em><em>props and renders a message that includes the </em><em>name prop.</em></p><pre>import React from &#39;react&#39;;<br>import Developer from &#39;./Developer.js&#39;;<br><br>function App(){<br>  const jobName = &quot;React Developer&quot;;<br><br>  return(<br>    &lt;&gt;<br>      &lt;h1&gt;How are You?&lt;/h1&gt;<br>      &lt;Developer name={jobName} /&gt;<br>    &lt;/&gt;<br>  );<br>}<br>export default App;<br></pre><p><em>This file defines the </em><em>App component, which renders a greeting and passes the </em><em>jobName variable to the </em><em>Developer component correctly.</em></p><h4>4.State</h4><p>State is like a memory for your components. it remembers things that might change, like a counter or a form input. State can change based on user actions (like clicking a button).</p><pre>import React from &#39;react&#39;;<br>import { useState } from &#39;react&#39;;<br><br>function Counter() {<br>  const [count, setCount] = useState(0);<br>  return &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Count: {count}&lt;/button&gt;;<br>}<br><br>export default Counter;</pre><p><em>This React code defines a </em><em>Counter component that uses the </em><em>useState hook to track a </em><em>count value, and each time the button is clicked, the count increases by 1 and is displayed on the button</em></p><h4>5.Event Handling</h4><p>In React, event handling is how you repond to user actions, like clicks, typing, or hovering.</p><pre>import React from &#39;react&#39;;<br><br>function Button() {<br>  function handleClick(){<br>    alert(&#39;Button clicked!);<br>  }<br><br>  return(<br>    &lt;button onClick={handleClick}&gt; Click me &lt;/button&gt;<br>  );<br>}<br><br>export default Button;</pre><p><em>This code defines a </em><em>Button component where the </em><em>handleClick function is triggered when the button is clicked, displaying an alert message (&quot;Button clicked!&quot;) using event handling with the </em><em>onClick attribute.</em></p><h4>6.Lifecycle Methods &amp; Hooks</h4><p>React uses lifecycle <strong>methods</strong> (in older code) or <strong>hooks</strong> (in modern code) to control what happens when a component is created or updated. It helps your app work smoothly.</p><pre>import React from &#39;react&#39;;<br>import { useEffect } from &#39;react&#39;;<br><br>function Timer() {<br>  useEffect(() =&gt; {<br>    const interval = setInterval(() =&gt; {<br>      console.log(&#39;Tick&#39;);<br>    }, 1000);<br><br>    return () =&gt; {<br>      clearInterval(interval); // Cleanup when component is removed<br>    };<br>  }, []);<br><br>  return &lt;p&gt;Timer is running!&lt;/p&gt;;<br>}<br><br>export default Timer;</pre><p><em>This code defines a </em><em>Timer component that uses the </em><em>useEffect hook to start a timer, which logs &quot;Tick&quot; to the console every second, and automatically stops the timer when the component is removed from the screen.</em></p><h4>7.Conditional Rendering</h4><p>Conditional rendering lets you show different content based on a condition. For example, you can show one message if the user is logged in and a different one if they are not.</p><pre>import React from &#39;react&#39;;<br><br>function Greeting(props) { <br>  return (<br>    &lt;div&gt;<br>      {props.isLoggedIn ? &lt;h1&gt;Welcome back!&lt;/h1&gt; : &lt;h1&gt;Please log in&lt;/h1&gt;}<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default Greeting;</pre><p><em>This </em><em>Greeting component uses conditional rendering to display &quot;Welcome back!&quot; if the </em><em>isLoggedIn prop is </em><em>true, and &quot;Please log in&quot; if </em><em>isLoggedIn is </em><em>false.</em></p><h4>8.Lists and Keys</h4><p>When displaying lists of items (like a list of names), React uses a special property called a “key” to help keep track of each item.</p><pre>//NameList.js<br><br>import React from &#39;react&#39;;<br><br>function NameList(props) {<br>  return (<br>    &lt;ul&gt;<br>      {props.names.map((name, index) =&gt; (<br>        &lt;li key={index}&gt;{name}&lt;/li&gt;<br>      ))}<br>    &lt;/ul&gt;<br>  );<br>}<br><br>export default NameList;</pre><pre>//App.js<br><br>import React from &#39;react&#39;;<br>import NameList from &#39;./NameList&#39;;<br><br>function App() {<br>  const names = [&#39;Alice&#39;, &#39;Bob&#39;, &#39;Charlie&#39;];<br>  return &lt;NameList names={names} /&gt;;<br>}<br><br>export default App;</pre><p><em>This code displays a list of names by passing an array of names from </em><em>App to the </em><em>NameList component, which uses </em><em>.map() to create </em><em>&lt;li&gt; elements with unique </em><em>keys for each name in the list.</em></p><h4>9.React Router</h4><p>React Router helps create navigation for multi-page apps. It lets you move between different pages without reloading the whole website.</p><pre>import React from &#39;react&#39;;<br>import { BrowserRouter as Router, Route, Link, Routes } from &#39;react-router-dom&#39;;<br>import Home from &#39;./Home&#39;;  // Import the Home component<br>import About from &#39;./About&#39;;  // Import the About component<br><br>function App() {<br>  return (<br>    &lt;Router&gt;<br>      &lt;div&gt;<br>        {/* Navigation Links */}<br><br>        &lt;Link to=&quot;/&quot;&gt;Home&lt;/Link&gt; &amp;nbsp;<br>        &lt;Link to=&quot;/about&quot;&gt;About&lt;/Link&gt;<br><br>        {/* Routes component ensures only one Route is rendered at a time */}<br><br>        &lt;Routes&gt;<br>          &lt;Route path=&quot;/&quot; element={&lt;Home /&gt;} /&gt;<br>          &lt;Route path=&quot;/about&quot; element={&lt;About /&gt;} /&gt;<br>        &lt;/Routes&gt;<br>      &lt;/div&gt;<br>    &lt;/Router&gt;<br>  );<br>}<br><br>export default App;</pre><p><em>This code sets up a simple React app using </em><strong><em>React Router</em></strong><em> to handle navigation, where the </em><em>Link components allow the user to navigate between different pages (</em><em>Home and </em><em>About), and the </em><em>Routes component renders the corresponding component (</em><em>Home or </em><em>About) based on the URL path (</em><em>/ or </em><em>/about).</em></p><h4>10.Component Composition</h4><p>You can create small, reusable components and combine them to build bigger, more complex UIs.</p><pre>// Blog.js<br>import React from &#39;react&#39;;<br>import Header from &#39;./Header&#39;;  // Import the Header component<br>import Footer from &#39;./Footer&#39;;  // Import the Footer component<br><br>function Blog() {<br>  return (<br>    &lt;div&gt;<br>      &lt;Header /&gt;  {/* Rendering the Header component */}<br>      &lt;div&gt;Blog Page&lt;/div&gt; <br>      &lt;Footer /&gt;  {/* Rendering the Footer component */}<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default Blog;</pre><p><em>This code shows how to combine smaller components like </em><em>Header and </em><em>Footer inside a main </em><em>Blog component to build a complete page.</em></p><h4>11.Redux (or Context API)</h4><p>Redux and the Context API help manage data that needs to be shared across multiple components. This is particularly useful for large applications where many components need access to the same data</p><p>Let’s go through it step-by-step. For this example, we’ll manage and control theme color state globally with Redux.</p><ol><li><strong>Install Redux Packages:</strong></li></ol><pre>npm install redux react-redux</pre><p>2. <strong>Create a Redux Store and Slice (Reducer) to Handle Theme State:</strong></p><pre>// themeSlice.js<br>import { createSlice } from &#39;@reduxjs/toolkit&#39;;<br><br>const themeSlice = createSlice({<br>  name: &#39;theme&#39;,<br>  initialState: &#39;light&#39;,<br>  reducers: {<br>    setTheme: (state, action) =&gt; action.payload,<br>  },<br>});<br><br>export const { setTheme } = themeSlice.actions;<br>export default themeSlice.reducer;</pre><p><em>Defines the initial theme state and an action (</em><em>setTheme) to update the theme in the Redux store.</em></p><p>3.<strong> Set up the Redux store with the Theme Reducer:</strong></p><pre>// store.js<br>import { configureStore } from &#39;@reduxjs/toolkit&#39;;<br>import themeReducer from &#39;./themeSlice&#39;;<br><br>const store = configureStore({<br>  reducer: {<br>    theme: themeReducer,<br>  },<br>});<br><br>export default store;</pre><p><em>Configures the Redux store to manage and hold the application’s theme state.</em></p><p>4. <strong>Provide the Redux Store to the App:</strong></p><pre>// index.js<br>import React from &#39;react&#39;;<br>import ReactDOM from &#39;react-dom&#39;;<br>import { Provider } from &#39;react-redux&#39;;<br>import store from &#39;./store&#39;;<br>import App from &#39;./App&#39;;<br><br>ReactDOM.render(<br>  &lt;Provider store={store}&gt;<br>    &lt;App /&gt;<br>  &lt;/Provider&gt;,<br>  document.getElementById(&#39;root&#39;)<br>);</pre><p><em>Wraps the main </em><em>&lt;App /&gt; component in a </em><em>&lt;Provider&gt; component to make the Redux store available throughout the app.</em></p><p>5. <strong>Now, the App component can dispatch an action to change the theme value in the store.</strong></p><pre>// App.js<br>import React from &#39;react&#39;;<br>import { useDispatch } from &#39;react-redux&#39;;<br>import { setTheme } from &#39;./themeSlice&#39;;<br>import ThemedButton from &#39;./ThemedButton&#39;;<br><br>function App() {<br>  const dispatch = useDispatch();<br><br>  // Set theme to &quot;dark&quot; when the App component is rendered<br>  React.useEffect(() =&gt; {<br>    dispatch(setTheme(&#39;dark&#39;));<br>  }, [dispatch]);<br><br>  return &lt;ThemedButton /&gt;;<br>}<br><br>export default App;</pre><p><em>Uses the </em><em>dispatch function to set the theme to </em><em>&#39;dark&#39; when the app loads.</em></p><p>6. <strong>ThemedButton Component (Read Theme)</strong></p><pre>// ThemedButton.js<br>import React from &#39;react&#39;;<br>import { useSelector } from &#39;react-redux&#39;;<br><br>function ThemedButton() {<br>  const theme = useSelector((state) =&gt; state.theme);<br><br>  return &lt;button className={theme}&gt;I am {theme}&lt;/button&gt;;<br>}<br><br>export default ThemedButton;</pre><p><em>Reads the current theme from the Redux store using </em><em>useSelector and displays it on a button.</em></p><p>If you don’t have a basic understanding of redux, you can’t understand this at once, but you can get a rough understanding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d5Jmno6eLdvKRw4GG8NWbA.png" /></figure><blockquote>So therefore, I will bring a complete exaplanation about redux in a separate article.</blockquote><h4>12. Testing (Jest, React Testing Library)</h4><p>Below is a complete example of a test using Jest and React Testing Library, along with a simple explanation.</p><pre>// Welcome.js<br>import React from &#39;react&#39;;<br><br>function Welcome() {<br>  return &lt;h1&gt;Hello, World!&lt;/h1&gt;;<br>}<br><br>export default Welcome;</pre><p><em>The </em><em>Welcome component displays a heading with the text &quot;Hello, World!&quot;</em></p><pre>// Welcome.test.js<br>import React from &#39;react&#39;;<br>import { render, screen } from &#39;@testing-library/react&#39;;<br>import &#39;@testing-library/jest-dom&#39;;<br>import Welcome from &#39;./Welcome&#39;;<br><br>test(&#39;renders Hello, World!&#39;, () =&gt; {<br>  render(&lt;Welcome /&gt;);<br>  expect(screen.getByText(&#39;Hello, World!&#39;)).toBeInTheDocument();<br>});</pre><p><em>In the test file (</em><em>Welcome.test.js), we use React Testing Library&#39;s </em><em>render to display the component, and </em><em>screen.getByText(&#39;Hello, World!&#39;) to find the text, followed by Jest&#39;s </em><em>toBeInTheDocument() to confirm its presence in the DOM.</em></p><p><em>This test checks that when the </em><em>Welcome component renders, it correctly includes the text &quot;Hello, World!&quot;</em></p><h4>13. <strong>Component Rendering</strong></h4><p>Rendering is when React displays or updates parts of your website. React re-renders a component when its data (state or props) changes.</p><pre>// Counter.js<br>import React from &#39;react&#39;;<br><br>function Counter({ count }) {<br>  console.log(&#39;Rendering Counter&#39;);<br>  return &lt;p&gt;Count: {count}&lt;/p&gt;;<br>}<br><br>export default Counter;</pre><p><em>The </em><em>Counter component in </em><em>Counter.js takes a </em><em>count prop, logs &quot;Rendering Counter&quot; to the console, and displays the current count in a paragraph.</em></p><pre>// App.js<br>import React from &#39;react&#39;;<br>import Counter from &#39;./Counter&#39;; // Importing the Counter component<br><br>function App() {<br>  const [count, setCount] = React.useState(0);<br><br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Component Rendering Example&lt;/h1&gt;<br>      &lt;Counter count={count} /&gt;<br>      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Increase Count&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default App;</pre><p><em>The </em><em>App component in </em><em>App.js manages the </em><em>count state, renders the </em><em>Counter component with the </em><em>count prop, and provides a button to increase the count, triggering re-renders of </em><em>Counter.</em></p><p>So, I will end this article here for today. React may seem complex at first, but understanding these core concepts — like components, state, and props — makes it much easier to build fun and interactive websites. Remember, each small step you take with React brings you closer to creating something amazing. So keep experimenting, building, and exploring! With a little practice, you’ll be creating web pages that people will love to use. <br><strong>Happy coding!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8651e93179c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>