LESSON 6
Branches
Learning objective: Work on features safely using branches.
Understand
Branches let you work without affecting the main code.
A branch is a separate line of work. Create one for each feature so the main branch stays stable. Switch between branches with git switch (or git checkout).
Analogy: A branch is like a sandbox copy where you can experiment without breaking the real thing.
See It in Action
Creating and switching:
git branch feature-nav
git switch feature-navHow it works: The first line creates a branch and the second moves onto it, so new commits do not touch
main.Try It Yourself
- Create a new branch.
- Switch to it.
- Make a commit on the branch.
Quick Quiz
Why use branches?
Challenge
Create a feature branch and make a commit on it.
Success condition: Your commit lives on a branch separate from main.
+10 XP
Lesson Complete
You answered correctly and completed the required practice. Your progress has been saved on this device.
Continue to next lesson →