007
LVL 00 — CADET PILOT SESSION 007 DAY 7

PARALLEL UNIVERSES

SYS.SCENARIO
🏢 "Tomorrow you get repo access," says the team lead. "But here's the #1 rule at PixelCraft: NOBODY commits directly to the main branch. Ever. You create a branch, do your work there, and request a merge. This protects the working codebase from everyone's experiments — including yours."
CONCEPTS.UNLOCKED
🌿
What a Branch Is
A parallel line of development. Work on features or fixes without affecting the stable codebase. Cheap to create, safe to experiment.
$
Branch Commands
git branch (list), git switch -c (create+switch), git switch main (go back), git branch -d (delete after merge).
📛
Naming Conventions
feature/add-blur-filter, bugfix/fix-upload-crash, intern/yourname/task-name. The name tells the team what the branch is for.
🔀
Merging
git merge feature-x — bring branch changes into the current branch. Fast-forward when clean, three-way merge when diverged.
Merge Conflicts
When two branches edit the same line. Git marks the conflict with <<<<<<< / ======= / >>>>>>>. You resolve it manually.
📊
Visualize Branches
git log --oneline --graph --all — see how branches diverge and merge. ASCII art that shows the shape of your project's history.
HANDS-ON.TASKS
01
Create & Switch Branches
git switch -c feature/add-greeting echo "Welcome to PixelCraft!" > welcome.txt git add . && git commit -m "Add welcome message"
02
Watch Files Appear & Disappear
git switch main # welcome.txt is GONE ls # Not here git switch feature/add-greeting ls # It's back!
Files literally appear and disappear as you switch branches. Each branch is a different version of reality. This is the "aha" moment.
03
Merge a Branch
git switch main git merge feature/add-greeting ls # welcome.txt is now in main! git branch -d feature/add-greeting # Clean up
04
Create a Merge Conflict

Deliberately cause a conflict:

# Branch A git switch -c branch-a echo "Version A" > shared.txt git add . && git commit -m "Branch A change" # Branch B (from main) git switch main git switch -c branch-b echo "Version B" > shared.txt git add . && git commit -m "Branch B change" # Merge both into main git switch main git merge branch-a # Works fine git merge branch-b # CONFLICT!
05
Resolve the Conflict

Open the conflicted file. You'll see:

<<<<<<< HEAD Version A ======= Version B >>>>>>> branch-b

Choose the correct content (or combine both). Remove the conflict markers. Save.

git add shared.txt git commit -m "Resolve merge conflict between branch-a and branch-b"
Merge conflicts are normal. They happen daily on real teams. The skill is staying calm, reading both sides, and choosing the right resolution.
06
Full Feature Workflow (x3)

Practice the full cycle three times with different branches:

# Repeat 3 times: git switch -c feature/feature-name # ... make changes, commit ... git switch main git merge feature/feature-name git branch -d feature/feature-name

Then visualize the result:

git log --oneline --graph --all
CS.DEEP-DIVE

Branching is state divergence.

Two versions of reality evolving independently. Merging is reconciliation — bringing them back together. This problem is universal.

// The same state-divergence problem:

Databases       → reconcile conflicting updates
                  from different servers
Multiplayer     → synchronize game state
                  between players
Google Docs     → resolve simultaneous edits
                  in real-time

// Git's three-way merge algorithm:
// 1. What was the common ancestor?
// 2. What did branch A change?
// 3. What did branch B change?
// Auto-resolve when possible.
// Ask the human when both changed the same thing.
"Branch Gymnastics"
[A] Create 3 feature branches simultaneously. Each modifies different files.
[B] Merge all 3 into main one by one. Resolve any conflicts that arise.
[C] Run git log --oneline --graph --all and screenshot the branch visualization.
REF.MATERIAL
TOOL
learngitbranching.js.org
The single best resource for understanding branches visually. Complete levels 1–8 for this session. Essential.
INTERACTIVEVISUALESSENTIAL
VIDEO
SuperSimpleDev
Step-by-step walkthrough of branching, merging, and conflict resolution with clear terminal demos.
BRANCHINGMERGING
ARTICLE
Vincent Driessen
The original "Git Flow" article. Read to understand how teams organize branches at scale. Reference for later sessions.
GIT FLOWTEAM WORKFLOW
VIDEO
freeCodeCamp
Dedicated tutorial on merge conflicts — creating them, understanding markers, resolving them, and prevention strategies.
CONFLICTSRESOLUTION
ARTICLE
Katie Sylor-Miller
Plain-English recipes for getting out of common Git messes. Bookmark this — you will need it.
TROUBLESHOOTINGRESCUE
// LEAVE EXCITED BECAUSE
You created parallel universes for your code. You worked in one universe while main stayed perfectly safe. You survived your first merge conflict — the thing that intimidates every new developer. Branches make you fearless.