Let's think about it this way for a second
In real-world development, every new feature usually isn't built directly on the main branch — it's built on its own separate branch. In this section, we'll practice creating a branch, switching to it, and then merging it back into main. We'll also learn the workflow for connecting our local repository to a remote repository on GitHub and pushing to it. By the end of this stage, our project's history will include branches, merges, and remote syncs.
Let's build it for real
Create a new branch called feature/projects-section with git branch, then switch to it with git switch. Add a Projects section to index.html (a heading plus a list of 2-3 projects) and commit it. Switch back to the main branch and merge it back in with git merge feature/projects-section. Finally, create an empty repository on GitHub, connect it with git remote add origin, and push with git push -u origin main.
Code Example
# Step 1: feature branch ဖန်တီးပြီး switch လုပ်ပါ
git branch feature/projects-section
git switch feature/projects-section
# Step 2: index.html ကို edit လုပ်ပြီး (Projects section ထည့်ပါ) commit လုပ်ပါ
git add index.html
git commit -m "Add projects section to homepage"
# Step 3: main branch ကို ပြန်သွားပြီး merge လုပ်ပါ
git switch main
git merge feature/projects-section
# Step 4: feature branch ကို ပြီးရင် ဖျက်နိုင်ပါတယ် (optional)
git branch -d feature/projects-section
# Step 5: GitHub remote ချိတ်ဆက်ပြီး push လုပ်ပါ
git remote add origin https://github.com/<your-username>/portfolio-site.git
git push -u origin mainRefreshing the GitHub repository page shows an index.html that includes the Projects section, along with the full commit history.Try it in 5 minutes
Create a new branch called feature/about-section, add an About Me section, and practice merging it back into main (5 minutes).
A quick word of caution
Before merging, always double-check which branch you're currently on with git status — merging on the wrong branch can leave your history in a tangled mess.