<?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: Kavin HBN</title>
    <description>The latest articles on DEV Community by Kavin HBN (@kavin_hbn_e6108b3e666949c).</description>
    <link>https://dev.to/kavin_hbn_e6108b3e666949c</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2169058%2Fdc0f2a5c-b741-4a58-b8b0-a07e1fcc2dca.jpg</url>
      <title>DEV Community: Kavin HBN</title>
      <link>https://dev.to/kavin_hbn_e6108b3e666949c</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kavin_hbn_e6108b3e666949c"/>
    <language>en</language>
    <item>
      <title>Why I’m Thinking of Switching My Portfolio to Astro.js ..</title>
      <dc:creator>Kavin HBN</dc:creator>
      <pubDate>Sat, 04 Jul 2026 08:12:55 +0000</pubDate>
      <link>https://dev.to/kavin_hbn_e6108b3e666949c/why-im-thinking-of-switching-my-portfolio-to-astrojs--4gcj</link>
      <guid>https://dev.to/kavin_hbn_e6108b3e666949c/why-im-thinking-of-switching-my-portfolio-to-astrojs--4gcj</guid>
      <description>&lt;h1&gt;
  
  
  Why I'm Thinking of Switching My Portfolio to Astro.js
&lt;/h1&gt;

&lt;p&gt;Lately I have been spending most of my time building auditing dashboards. Working on data-highly interactive applications changes the way you think. After a while my default workflow became simple: create a new &lt;strong&gt;React + Vite&lt;/strong&gt; project. Start coding.&lt;/p&gt;

&lt;p&gt;It's a stack for building web applications.&lt;/p&gt;

&lt;p&gt;When I looked at my personal portfolio and blog, I stopped and asked myself:&lt;/p&gt;

&lt;h1&gt;
  
  
  Why am I using the setup for a website that is mostly static?
&lt;/h1&gt;

&lt;p&gt;A portfolio is not a dashboard. It does not manage state, update data in real time, or require every component to become interactive the moment the page loads.&lt;/p&gt;

&lt;p&gt;Yet with my React setup the browser still has to download and execute JavaScript for the entire application before everything becomes interactive.&lt;/p&gt;

&lt;p&gt;While browsing through developer blogs and discussions, I kept seeing one framework mentioned again and again: &lt;strong&gt;Astro&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The more I read about it, the more it seemed designed for exactly this type of website.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Problem with Hydrating Everything
&lt;/h1&gt;

&lt;p&gt;A typical React application works by hydrating the page.&lt;/p&gt;

&lt;p&gt;For example, a React application starts like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ReactDOM&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dom/client&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./App&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createRoot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;root&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;

&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;App&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;

&lt;span class="p"&gt;);&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything inside ``eventually becomes part of one large JavaScript application.&lt;/p&gt;

&lt;p&gt;Before users can fully interact with the page, the browser needs to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Download the JavaScript&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Parse it&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Execute it&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hydrate the UI&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For applications like dashboards admin panels or collaborative tools, this trade-off is completely reasonable.&lt;/p&gt;

&lt;p&gt;For a portfolio?&lt;/p&gt;

&lt;p&gt;Most visitors just want to&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Read about you&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;View your projects&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open your GitHub&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Read your blog&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hydrating the page feels unnecessary.&lt;/p&gt;

&lt;p&gt;I mean think about it. My portfolio does not need to be interactive all the time.&lt;/p&gt;




&lt;h1&gt;
  
  
  Astro Takes an Approach
&lt;/h1&gt;

&lt;p&gt;Astro follows a different philosophy.&lt;/p&gt;

&lt;p&gt;Of assuming everything needs JavaScript, it assumes &lt;strong&gt;nothing does&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A simple Astro page looks like this:&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;astro&lt;/p&gt;




&lt;p&gt;const title = "My Portfolio";&lt;/p&gt;









{title}





&lt;h1&gt;Hello I'm Kavin&lt;/h1&gt;

&lt;p&gt;Welcome to my portfolio.&lt;/p&gt;





&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;When you build the project:&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;

&lt;p&gt;npm run build&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;Astro outputs HTML.&lt;/p&gt;

&lt;p&gt;That means visitors immediately receive content without waiting for a JavaScript bundle.&lt;/p&gt;

&lt;p&gt;I like that.&lt;/p&gt;




&lt;h1&gt;
  
  
  Islands Architecture
&lt;/h1&gt;

&lt;p&gt;One of Astro's interesting ideas is **island architecture.&lt;/p&gt;

&lt;p&gt;By making the whole page interactive, Astro only hydrates the components that actually need JavaScript.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;astro&lt;/p&gt;




&lt;p&gt;import ThemeToggle from "../components/ThemeToggle.jsx";&lt;/p&gt;

&lt;p&gt;import ProjectCarousel from "../components/ProjectCarousel.jsx";&lt;/p&gt;




&lt;h1&gt;My Portfolio&lt;/h1&gt;





&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;Here the page itself remains static.&lt;/p&gt;

&lt;p&gt;Only the components that need interactivity receive JavaScript.&lt;/p&gt;

&lt;p&gt;That's really cool.&lt;/p&gt;




&lt;h1&gt;
  
  
  Client Directives
&lt;/h1&gt;

&lt;p&gt;Astro gives you control over &lt;strong&gt;when&lt;/strong&gt; a component should become interactive.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;client:load&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;astro&lt;/p&gt;



&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it does&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Downloads JavaScript immediately&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hydrates soon as the page loads&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Best for&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Theme toggles&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigation menus&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Search boxes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;buttons&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I can see why this is useful.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;client:visible&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;astro&lt;/p&gt;



&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it does&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Waits until the component appears on the screen&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Downloads JavaScript only when needed&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Imagine your portfolio contains an interactive project carousel near the bottom of the page.&lt;/p&gt;

&lt;p&gt;If a visitor never scrolls far, Astro never downloads its JavaScript.&lt;/p&gt;

&lt;p&gt;That's bandwidth saved without writing any optimization code.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why This Matters
&lt;/h1&gt;

&lt;p&gt;Instead of sending JavaScript for everything upfront, Astro sends JavaScript only where it's actually needed.&lt;/p&gt;

&lt;p&gt;That means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Smaller JavaScript bundles&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Faster page loads&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lower memory usage&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Better Core Web Vitals&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Less work for the browser&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For content websites, this approach makes a lot of sense.&lt;/p&gt;

&lt;p&gt;I think it's a fit for my portfolio.&lt;/p&gt;




&lt;h1&gt;
  
  
  SEO Benefits
&lt;/h1&gt;

&lt;p&gt;Another thing I like is how Astro handles SEO.&lt;/p&gt;

&lt;p&gt;Since pages are rendered as HTML by default, search engines can immediately read the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Page title&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Meta description&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Headings&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Content&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;links&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They don't have to wait for a large JavaScript application to finish executing before indexing the page.&lt;/p&gt;

&lt;p&gt;For blogs and portfolios, that's an advantage.&lt;/p&gt;




&lt;h1&gt;
  
  
  Where Astro Makes the Sense
&lt;/h1&gt;

&lt;p&gt;After reading more about Astro, I realized it fits perfectly for websites where content's the main focus.&lt;/p&gt;

&lt;p&gt;Some examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Developer portfolios&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Personal blogs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Documentation websites&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Company landing pages&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Marketing websites&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;E-commerce storefronts where fast loading improves user experience&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That does not mean React is obsolete.&lt;/p&gt;

&lt;p&gt;If I were building another auditing dashboard with forms, charts, filters, and live updates, I'd still reach for React without hesitation.&lt;/p&gt;

&lt;p&gt;The tool simply matches the problem.&lt;/p&gt;

&lt;p&gt;I like that.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;This was not really about finding a "framework.&lt;/p&gt;

&lt;p&gt;It was about choosing the one for the job.&lt;/p&gt;

&lt;p&gt;For years my mindset was&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"I'll just use React."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now it's becoming:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"What does this project actually need?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For interactive web applications, React is still one of the best choices available.&lt;/p&gt;

&lt;p&gt;For a portfolio or blog Astro's approach of shipping static HTML first and loading JavaScript only when it's needed feels much more appropriate.&lt;/p&gt;

&lt;p&gt;I'm seriously considering rebuilding my portfolio with Astro—not because React is not good enough. Because Astro seems like the better fit for the kind of website I'm trying to build.&lt;/p&gt;

&lt;p&gt;Sometimes the biggest performance improvement does not come from writing code.&lt;/p&gt;

&lt;p&gt;It comes from choosing the tool before writing any code at all.&lt;/p&gt;

</description>
      <category>astro</category>
      <category>seo</category>
      <category>webdev</category>
      <category>devops</category>
    </item>
    <item>
      <title>Git for New Devs: Your Code's Grand Adventure !</title>
      <dc:creator>Kavin HBN</dc:creator>
      <pubDate>Mon, 23 Jun 2025 10:39:13 +0000</pubDate>
      <link>https://dev.to/kavin_hbn_e6108b3e666949c/git-for-new-devs-your-codes-grand-adventure-567f</link>
      <guid>https://dev.to/kavin_hbn_e6108b3e666949c/git-for-new-devs-your-codes-grand-adventure-567f</guid>
      <description>&lt;h1&gt;
  
  
  Git for Beginners: A Simple Guide to Your Git Workflow
&lt;/h1&gt;

&lt;p&gt;When you are learning Git, the number of commands can feel overwhelming.&lt;/p&gt;

&lt;p&gt;The good news is that most of your day-to-day work follows the simple Git workflow.&lt;/p&gt;

&lt;p&gt;Once you understand that Git workflow, handling problems like merge conflicts or rejected Git pushes becomes much easier.&lt;/p&gt;

&lt;p&gt;Git for beginners can be easy to learn.&lt;/p&gt;

&lt;p&gt;Think of Git as a journal for your project.&lt;/p&gt;

&lt;p&gt;Every meaningful change is recorded so you can track your progress collaborate with others using Git and even travel back in time if something goes wrong with Git.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Normal Git Workflow
&lt;/h1&gt;

&lt;p&gt;Most of the time you will follow these steps in your Git workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Initialize Your Git Repository
&lt;/h2&gt;

&lt;p&gt;When starting a project initialize Git inside your project folder using Git.&lt;/p&gt;

&lt;p&gt;If you are using GitHub connect your Git repository to the remote Git repository using Git.&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;If you are using GitHub you can connect your Git repository to the remote Git repository using Git.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;
git remote add origin https://github.com/your-username/your-repository.git

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now your local project knows where it should push and pull changes using Git.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 2: Stage Your Changes in Git
&lt;/h2&gt;

&lt;p&gt;After writing or modifying code tell Git which files should be included in the next Git commit.&lt;/p&gt;

&lt;p&gt;Stage every changed file in Git:&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or stage a file in Git:&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 app.js

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 3: Create a Commit in Git
&lt;/h2&gt;

&lt;p&gt;A commit in Git is a snapshot of your project at a specific point in time using Git.&lt;/p&gt;

&lt;p&gt;Write meaningful commit messages that explain what changed in your Git project not that something changed in your Git project.&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;" project setup"&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Good examples of commit messages in Git are:&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;"Add user authentication"&lt;/span&gt;

git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Fix login validation bug"&lt;/span&gt;

git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Update portfolio homepage"&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 4: Push Your Changes in Git
&lt;/h2&gt;

&lt;p&gt;Upload your commits to GitHub using Git.&lt;/p&gt;

&lt;p&gt;The first push using Git:&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 &lt;span class="nt"&gt;-u&lt;/span&gt; origin main

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Future pushes using Git:&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

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point your work is safely stored both locally and on GitHub using Git.&lt;/p&gt;




&lt;h1&gt;
  
  
  When Things Do Not Go as Planned in Git
&lt;/h1&gt;

&lt;p&gt;Working is simple in Git.&lt;/p&gt;

&lt;p&gt;Working with developers introduces a few common situations you will eventually encounter in Git.&lt;/p&gt;

&lt;p&gt;Fortunately they are easy to fix once you understand what is happening in Git.&lt;/p&gt;




&lt;h1&gt;
  
  
  Problem 1: Push Rejected in Git
&lt;/h1&gt;

&lt;p&gt;Sometimes Git refuses your push. Shows a message similar to this in Git:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
Updates were rejected because the remote contains work that you do not have locally.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means someone has already pushed commits to GitHub that you do not have on your computer using Git.&lt;/p&gt;

&lt;p&gt;Git blocks your push to prevent overwriting their work in Git.&lt;/p&gt;




&lt;h2&gt;
  
  
  Solution: Pull First in Git
&lt;/h2&gt;

&lt;p&gt;Download the changes from GitHub using Git.&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;If your changes and the remote changes do not overlap Git merges everything automatically using Git.&lt;/p&gt;

&lt;p&gt;Then simply push again using Git.&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

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Problem 2: Merge Conflict in Git
&lt;/h1&gt;

&lt;p&gt;Sometimes both you and another developer edit the part of the same file in Git.&lt;/p&gt;

&lt;p&gt;Git does not know which version should be kept in Git.&lt;/p&gt;

&lt;p&gt;Of guessing it asks you to decide in Git.&lt;/p&gt;

&lt;p&gt;You will see something to this in Git:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD

My version

=======

Their version

&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; origin/main

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  How to Resolve It in Git
&lt;/h2&gt;

&lt;p&gt;Open the file and decide which code should remain in Git.&lt;/p&gt;

&lt;p&gt;You can keep your version keep their version or combine both versions in Git.&lt;/p&gt;

&lt;p&gt;After editing the file remove all the conflict markers in Git.&lt;/p&gt;

&lt;p&gt;Then stage the file in Git.&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 filename

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a commit in Git.&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;"Resolve merge conflict"&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally push your updated code in Git.&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

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Working Safely with Branches in Git
&lt;/h1&gt;

&lt;p&gt;Branches let you develop features without affecting the main project in Git.&lt;/p&gt;

&lt;p&gt;Create a new branch in Git.&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/login

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Work in Git.&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.

git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Add login page"&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Switch to the main branch in Git.&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;Merge your feature in Git.&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/login

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once merged your new feature becomes part of the project in Git.&lt;/p&gt;




&lt;h1&gt;
  
  
  Undoing Commits in Git
&lt;/h1&gt;

&lt;p&gt;Everyone makes mistakes in Git.&lt;/p&gt;

&lt;p&gt;Git provides ways to undo changes in Git.&lt;/p&gt;

&lt;p&gt;View your commit history in Git.&lt;br&gt;
&lt;/p&gt;

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

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Undo the commit but keep your code in Git.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;
git reset &lt;span class="nt"&gt;--soft&lt;/span&gt; HEAD~1

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Undo the commit and permanently remove those changes in Git.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;
git reset &lt;span class="nt"&gt;--hard&lt;/span&gt; HEAD~1

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use &lt;code&gt;--hard&lt;/code&gt; carefully because the discarded changes cannot be recovered easily in Git.&lt;/p&gt;




&lt;h1&gt;
  
  
  Understanding &lt;code&gt;git status&lt;/code&gt; in Git
&lt;/h1&gt;

&lt;p&gt;One of the useful commands is in Git:&lt;br&gt;
&lt;/p&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;It tells you exactly what is happening inside your repository in Git.&lt;/p&gt;

&lt;p&gt;Common status indicators include:&lt;/p&gt;

&lt;p&gt;| Symbol | Meaning&lt;/p&gt;

&lt;p&gt;| ------ | ------------------------------ |&lt;/p&gt;

&lt;p&gt;M`    | Modified file                  |&lt;/p&gt;

&lt;p&gt;| &lt;code&gt;A&lt;/code&gt;    | Newly added file               |&lt;/p&gt;

&lt;p&gt;| &lt;code&gt;D&lt;/code&gt;    | Deleted file                   |&lt;/p&gt;

&lt;p&gt;| &lt;code&gt;U&lt;/code&gt;    | Unmerged file (merge conflict) |&lt;/p&gt;

&lt;p&gt;| &lt;code&gt;??&lt;/code&gt;   | Untracked file                 |&lt;/p&gt;

&lt;p&gt;Running &lt;code&gt;git status&lt;/code&gt; frequently helps you understand what Git is tracking before committing in Git.&lt;/p&gt;




&lt;h1&gt;
  
  
  Common Git Workflow Cheat Sheet in Git
&lt;/h1&gt;

&lt;p&gt;Initialize a repository in Git:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`bash&lt;/p&gt;

&lt;p&gt;git init&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Stage files in Git:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`bash&lt;/p&gt;

&lt;p&gt;git add.&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Create a commit in Git:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`bash&lt;/p&gt;

&lt;p&gt;git commit -m "Your message"&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Push to GitHub in Git:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`bash&lt;/p&gt;

&lt;p&gt;git push&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Download changes in Git:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`bash&lt;/p&gt;

&lt;p&gt;git pull&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Create a new branch in Git:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`bash&lt;/p&gt;

&lt;p&gt;git checkout -b feature-name&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Switch branches in Git:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`bash&lt;/p&gt;

&lt;p&gt;git checkout main&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Merge a branch in Git:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`bash&lt;/p&gt;

&lt;p&gt;git merge feature-name&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;View commit history in Git:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`bash&lt;/p&gt;

&lt;p&gt;git log --oneline&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Check repository status in Git:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`bash&lt;/p&gt;

&lt;p&gt;git status&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts on Git
&lt;/h1&gt;

&lt;p&gt;Git can seem intimidating at first but most developers use the same handful of commands every day in Git.&lt;/p&gt;

&lt;p&gt;The basic Git workflow is simple:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Make changes in Git.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Stage them with &lt;code&gt;git add&lt;/code&gt; in Git.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save them with &lt;code&gt;git commit&lt;/code&gt; in Git.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Share them using &lt;code&gt;git push&lt;/code&gt; in Git.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As you collaborate with others you will occasionally encounter pull requests merge conflicts and branches in Git.&lt;/p&gt;

&lt;p&gt;These are not signs that something's wrong. They are simply part of working with version control in Git.&lt;/p&gt;

&lt;p&gt;The more you practice the more Git starts to feel less like a list of commands and like a reliable safety net for your code, in Git.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>github</category>
      <category>beginners</category>
      <category>developers</category>
    </item>
  </channel>
</rss>
