Lesson 1: The Parallel Universe
Imagine you could create a parallel universe where you experiment freely — and if the experiment succeeds, merge it back into reality. If it fails, just delete that universe. No consequences. That's what branches do in Git.
What is a Branch?
A branch is a separate line of development. It's a copy of your project where you can make changes without affecting the main branch.
main: A ── B ── C
\
feature: D ── E ── F
mainstays stable whilefeatureevolves independently.- When the feature is ready, you merge it back.
Why Branches Matter in DevOps
- Feature branches — Each new feature gets its own branch.
- Hotfix branches — Emergency fixes without disrupting development.
- Release branches — Prepare a release while development continues.
- Environment branches —
staging,productionreflect deployed states.
Creating a Branch
git branch feature/login # Create a new branch
git checkout feature/login # Switch to it
Or the shortcut:
git checkout -b feature/login # Create AND switch in one command
Switching Branches
git checkout main # Switch back to main
git switch feature/login # Modern alternative to checkout
Listing Branches
git branch # Local branches
git branch -a # All branches (including remote)
git branch -v # Branches with last commit info
Branch Naming Conventions
| Pattern | Example | Use Case |
|---------|---------|----------|
| feature/ | feature/user-auth | New features |
| bugfix/ | bugfix/login-crash | Bug fixes |
| hotfix/ | hotfix/security-patch | Urgent production fixes |
| release/ | release/v2.0 | Release preparation |
booting...
Mission Objective
Create your first parallel universe:
- Create it: Run
git branch feature/loginto create a new branch. - Enter it: Switch to it with
git checkout feature/login. - Survey: Run
git branch -ato see all branches.