Creating Your First Branch

Create a real branch, commit on it, switch back to master. Master never moves — confirmed directly, not just described.

Fifteen real commits sit on master right now — the whole cookie, pasta, soup, and waffle collection, exactly as it should be. You have an idea for a ghost pepper wings recipe, and it genuinely does not belong mixed in with the tested, working collection while you are still figuring it out.\n\nA branch is the real answer: a new, independent line of commits starting from wherever master currently is. Commits made on the branch exist only there until you decide otherwise — master is never touched by them, confirmed directly in this lab rather than taken on faith.

Creating and Switching in One Step

git checkout -b spicy-experiments

Creates a new branch pointing at the current commit, and moves HEAD to it in the same command. From this point on, any commit lands on spicy-experiments, not master.

Committing Only on the Branch

# create ghost-pepper-wings.md
git add ghost-pepper-wings.md
git commit -m "Add ghost pepper chicken wings recipe"

This commit's parent is master's tip, but it exists only on spicy-experiments — master's own pointer has not moved at all.

Switching Back and Verifying

git checkout master
ls                      # ghost-pepper-wings.md is genuinely gone
git log --oneline --all --decorate --graph

--all shows every branch's history at once; the graph makes it visible that spicy-experiments split off and master's own line never changed.

Branch

A movable pointer to a specific commit. Creating one costs nothing and copies nothing — it is genuinely just a new named pointer, confirmed directly in the next lesson by looking at exactly what a branch is made of on disk.

HEAD

Git's record of which branch (and therefore which commit) you are currently on. git checkout -b spicy-experiments moves HEAD to point at the new branch — every commit from then on advances that branch specifically, not whichever branch HEAD pointed at before.

🌿 Create and Switch to a New Branch

Create the spicy-experiments branch and move onto it in one real command.

cd ~/recipes && git checkout -b spicy-experiments

student@lab:~$ cd ~/recipes && git checkout -b spicy-experiments Switched to a new branch 'spicy-experiments'

📝 Commit Only on This Branch

Write the ghost pepper wings recipe and commit it — this commit will exist only on spicy-experiments.

cd ~/recipes && echo "Ghost Pepper Chicken Wings" > ghost-pepper-wings.md
cd ~/recipes && echo "" >> ghost-pepper-wings.md
cd ~/recipes && echo "Toss wings in ghost pepper hot sauce, bake at 220C for 25 minutes." >> ghost-pepper-wings.md
cd ~/recipes && git add ghost-pepper-wings.md
cd ~/recipes && git commit -m 'Add ghost pepper chicken wings recipe'

student@lab:~$ cd ~/recipes && echo "Ghost Pepper Chicken Wings" > ghost-pepper-wings.md student@lab:~$ cd ~/recipes && echo "" >> ghost-pepper-wings.md student@lab:~$ cd ~/recipes && echo "Toss wings in ghost pepper hot sauce, bake at 220C for 25 minutes." >> ghost-pepper-wings.md student@lab:~$ cd ~/recipes && git add ghost-pepper-wings.md student@lab:~$ cd ~/recipes && git commit -m 'Add ghost pepper chicken wings recipe' [spicy-experiments de3eb14] Add ghost pepper chicken wings recipe 1 file changed, 3 insertions(+) create mode 100644 ghost-pepper-wings.md

↩️ Switch Back and Verify Master Never Moved

Return to master and confirm the ghost pepper file is genuinely gone — then view the full real graph of both branches.

cd ~/recipes && git checkout master
cd ~/recipes && ls
cd ~/recipes && git log --oneline --all --decorate --graph
cd ~/recipes && git branch

student@lab:~$ cd ~/recipes && git checkout master Switched to branch 'master' student@lab:~$ cd ~/recipes && ls cookies.md pasta.md salad.md soup.md waffles.md student@lab:~$ cd ~/recipes && git log --oneline --all --decorate --graph * de3eb14 (spicy-experiments) Add ghost pepper chicken wings recipe * 7451729 (HEAD -> master) Increase butter back to 175g for a richer flavor * 59cee07 Reduce butter to 150g per taste-test feedback * 22779d0 Add butter quantity to cookie ingredients * 9db68e6 Add variations note to cookie recipe * dda949a Credit the recipe source in the cookie title * c7a2617 Add step-by-step instructions to cookie recipe * 8c8aee6 Add Belgian waffles recipe * 5856011 Add basic garden salad recipe * fd509ba asdf * c764cd9 Add prep time estimates to all three recipes * 1aa939c Add salt to taste note in soup recipe * 56c4ee4 fixed stuff * b5dba00 Add chicken noodle soup recipe * cd7e65b Add ingredients list and pasta recipe * 7fb33b3 Add chocolate chip cookie recipe student@lab:~$ cd ~/recipes && git branch * master spicy-experiments

Lab 1.3.1 complete. A real branch, a real commit that exists only there, and master genuinely untouched:\n\n\n Branch created and switched to : ✅ git checkout -b\n Commit made only on the branch : ✅ confirmed via graph\n Master never moved : ✅ confirmed via ls + log\n

Enable JavaScript to run the live terminal and track your progress.