Branches let you work on new features or experiments without affecting the main codebase. Think of them as parallel timelines for your project.
Why Use Branches?
- Work on features without breaking the main code
- Multiple people can work on different things simultaneously
- Easy to discard experiments that don't work out
- Clean history when merging completed features
Create a New Branch
Terminal
# Create and switch to a new branch
git checkout -b feature/new-navigation
# Or with newer Git versions
git switch -c feature/new-navigationSwitch Between Branches
Terminal
# Switch to an existing branch
git checkout main
# See all branches
git branchBranch Naming Conventions
Most teams use prefixes to categorize branches:
- feature/ - New features (feature/user-profile)
- fix/ - Bug fixes (fix/login-error)
- design/ - Design changes (design/new-color-scheme)
- docs/ - Documentation (docs/api-guide)
Always Know Your Branch
Before making changes, always check which branch you're on with "git branch" or look at your terminal prompt. Committing to the wrong branch is a common mistake!
Lesson Complete!
- Create branches for new work
- Switch between branches
- Understand branch naming conventions
You're ready to work safely with branches!
The patterns behind this lesson
Collaborative AIEnable effective collaboration between multiple users and AI within shared workflows.Contextual AssistanceOffer timely, proactive help and suggestions based on user context, history, and needs.Error Recovery & Graceful DegradationFail gracefully with clear recovery paths when things go wrong.