Branches: parallel versions of the project
What a branch is, why work happens on short-lived branches next to main, and how to read branches on GitHub: the branch selector, ahead and behind, stale branches and graphs with several lanes.
Lesson 4 of 15~32 min of learningIncludes ~19 min for questions and tasks
Contents1 of 65 steps
You
Daniel
feature/checkout-redesign, and all that week the live site stayed exactly as it was.You
Daniel
main. That's when the button broke, and ten minutes later we reverted the merge. I'll confess the details at the end of the lesson.Alex Tutor
main doesn't notice.main is a branch too: the default branch. GitHub opens it first, and at CatChow it's the version that gets deployed to the site. In older repositories it's often called master.Alex Tutor
Question 1
Daniel adds a new commit to fix/checkout-button. Customers on the CatChow site see the change right away.
You
Alex Tutor
fix/checkout-button from the latest commit on main.Alex Tutor
e7c3b19Add summer promo bannerf02a6d4Update FAQ answers3a9d1c4Reproduce bug in a test8be2f70Add cat treats bundlemainb7e4a05Re-enable button after cart editsfix/checkout-button
Commit graph, oldest first: main and the branch fix/checkout-button 1. commit e7c3b19 on main "Add summer promo banner" 2. commit f02a6d4 on main "Update FAQ answers" 3. branch fix/checkout-button starts from commit f02a6d4 4. commit 3a9d1c4 on fix/checkout-button "Reproduce bug in a test" 5. commit 8be2f70 on main "Add cat treats bundle" 6. commit b7e4a05 on fix/checkout-button "Re-enable button after cart edits" (highlighted)
You
main. The right one curves out of "Update FAQ answers" and has two commits of its own.Alex Tutor
main didn't wait: "Add cat treats bundle" landed there while Daniel was working. The two lines now differ in both directions.Alex Tutor
Question 2
You switch the branch selector to feature/gift-wrap. Which commits are in the history of that branch? Select all that apply.
m1Add reviews blockm2Fix rating starsg1Add gift wrap optionm3Update footer linksmaing2Add gift wrap pricefeature/gift-wrap
Commit graph, oldest first: main and feature/gift-wrap 1. commit m1 on main "Add reviews block" 2. commit m2 on main "Fix rating stars" 3. branch feature/gift-wrap starts from commit m2 4. commit g1 on feature/gift-wrap "Add gift wrap option" 5. commit m3 on main "Update footer links" 6. commit g2 on feature/gift-wrap "Add gift wrap price"
Alex Tutor
main. It lists the branches, and the search field filters them by name.You
fix/checkout-button. The file list looks the same, but the latest commit bar now says "Re-enable button after cart edits".Alex Tutor
/tree/fix/checkout-button. Switching only changes what you see. It edits nothing.Daniel
Alex Tutor
main".Alex Tutor
Question 3
A colleague sends you a link to config/prices.json. The address contains /blob/feature/subscription/, and the file says delivery costs 69 UAH. What can you conclude?
You
Alex Tutor
main doesn't: Daniel's two. Behind counts the commits main has and the branch doesn't: the cat treats bundle.You
main has moved on without the branch.Alex Tutor
Daniel
main into my branch whenever I want. But the longer I wait, the more surprises pile up.Alex Tutor
Question 4
What will GitHub show for feature/subscription compared with main?
c1Add blog sectionc2Add author pagess1Add subscription plansc3Fix blog datess2Add subscription forms3Add plan pricesfeature/subscriptionc4Speed up imagesmain
Commit graph, oldest first: main and feature/subscription 1. commit c1 on main "Add blog section" 2. commit c2 on main "Add author pages" 3. branch feature/subscription starts from commit c2 4. commit s1 on feature/subscription "Add subscription plans" 5. commit c3 on main "Fix blog dates" 6. commit s2 on feature/subscription "Add subscription form" 7. commit s3 on feature/subscription "Add plan prices" 8. commit c4 on main "Speed up images"
Alex Tutor
View all branches inside the selector, and you get the branches page: every branch with its last update, its behind and ahead numbers and its pull request.Active holds branches with recent commits. Stale holds the ones that haven't had a commit for about three months.Alex Tutor
main
Default branch. Updated yesterday
feature/free-delivery-1000
Updated 3 hours ago · 0 behind, 3 ahead
fix/checkout-button
Updated yesterday · 1 behind, 2 ahead
content/delivery-copy
Updated last week · 2 behind, 1 ahead
feature/loyalty-points
Updated 5 months ago · 86 behind, 12 ahead
You
content/delivery-copy is Emma's! So our content marketer did move her texts into the repository.Alex Tutor
You
feature/loyalty-points: twelve commits ahead, 86 behind, untouched for five months. Is that an abandoned project?Daniel
main has changed too much since then.Alex Tutor
Alex Tutor
Question 5
Which of these branches will GitHub list under Stale? Select all that apply.
feature/wishlist
Last commit 4 months ago
fix/cart-rounding
Last commit 2 days ago
content/spring-sale
Last commit 2 months ago
docs/returns-policy
Last commit 7 months ago
feature/subscription
Last commit 3 weeks ago
You
fix/, feature/, content/. Is that a GitHub rule?Daniel
131-checkout-button, or the author's name, like daniel/checkout-button. And names GitHub generates itself, such as revert-97-feature/checkout-redesign.You
Daniel
Revert button created that branch for me.Alex Tutor
hotfix/ and release/ belong to git flow, a workflow we'll compare with ours in module 4.Alex Tutor
Question 6
Match each branch name with what it most likely tells you.
Tap an answer, then tap the row it belongs to. You can also drag.
fix/cart-total-roundingfeature/gift-cardsdocs/setup-guide142-delivery-maprevert-97-feature/checkout-redesign
Answers left to place
Alex Tutor
main, make a few commits, open a pull request, merge, delete.You
Alex Tutor
main. The branch name was only a pointer, and its task is finished.Delete branch button on the pull request page. And if someone needs the branch back, the same page has Restore branch.Daniel
Alex Tutor
Question 7
The pull request is merged, and Daniel clicks Delete branch. What happens to the fix from commit f1?
a1Add contacts pagef1Fix broken footer linksfix/footer-linksa2Update cat food photosa3Merge pull request #88main
Commit graph, oldest first: fix/footer-links after the merge 1. commit a1 on main "Add contacts page" 2. branch fix/footer-links starts from commit a1 3. commit f1 on fix/footer-links "Fix broken footer links" 4. commit a2 on main "Update cat food photos" 5. merge commit a3: fix/footer-links merged into main "Merge pull request #88"
Alex Tutor
main on the left, his redesign branch on the right.Alex Tutor
4d2a8e1Add order tracking link61b9f3cNew checkout button stylesd18e6a0Add cookie notice bar (#95)main92c4b1fMove button to sticky footer0a7f5e3Update button textsfeature/checkout-redesign
Commit graph, oldest first: March: the checkout redesign before the merge 1. commit 4d2a8e1 on main "Add order tracking link" 2. branch feature/checkout-redesign starts from commit 4d2a8e1 3. commit 61b9f3c on feature/checkout-redesign "New checkout button styles" 4. commit d18e6a0 on main "Add cookie notice bar (#95)" (highlighted) 5. commit 92c4b1f on feature/checkout-redesign "Move button to sticky footer" 6. commit 0a7f5e3 on feature/checkout-redesign "Update button texts"
Daniel
main. My branch was one commit behind, and I never looked.You
Daniel
main had both for the first time. On phones the bar sat right on top of my button, and nobody could tap it. Hence the revert.Alex Tutor
Daniel
main. It has worked ever since.Alex Tutor
Question 8
Which statements about this graph are true? Select all that apply.
e7c3b19Add summer promo bannerf02a6d4Update FAQ answerse19c3b7Rewrite delivery page copycontent/delivery-copy3a9d1c4Reproduce bug in a test8be2f70Add cat treats bundlemainb7e4a05Re-enable button after cart editsfix/checkout-button
Commit graph, oldest first: Three lines of work in catchow/website 1. commit e7c3b19 on main "Add summer promo banner" 2. branch content/delivery-copy starts from commit e7c3b19 3. commit f02a6d4 on main "Update FAQ answers" 4. commit e19c3b7 on content/delivery-copy "Rewrite delivery page copy" 5. branch fix/checkout-button starts from commit f02a6d4 6. commit 3a9d1c4 on fix/checkout-button "Reproduce bug in a test" 7. commit 8be2f70 on main "Add cat treats bundle" 8. commit b7e4a05 on fix/checkout-button "Re-enable button after cart edits"
Alex Tutor
You
fix/checkout-button, two ahead of main, and the site shows main.Alex Tutor
Daniel
Alex Tutor
Question 9Short answer · AI-checked task
Support asks: "Daniel says the checkout fix is ready, and I can see his commits on GitHub. Why do customers still get a grey button?" The fix is on fix/checkout-button, 2 commits ahead of main, and not merged yet. Write a 2–3 sentence answer for support without Git jargon.
Write your answer and get a score with feedback from our AI reviewer.
Log in to get AI feedbackYou
Alex Tutor
That’s the lesson. You answered every task — nicely done.