brewly — Ch.2 · Your first branch
Exercise 1 of 7
Before you start
What is a branch?
A branch is a movable name pointing at a commit. New commits move the branch you are on, so your work stays separate from main until you merge it.
Teams often name branches after their purpose, such as feature/search-box.
- git branch
- list branches;
*marks the one you are on - git switch -c <name>
- create a branch and switch to it
- git switch <name>
- switch to a branch that already exists
Committing on your branch
The "Write the code" button edits the files. Stage and commit as usual; the commit goes to the branch you are on.
- git status
- which branch am I on, and what changed?
- git add <file>
- stage a file
- git commit -m "What you did"
- commit it
You can reopen this any time with “Lesson”.
import { menu } from './menu.js'import { renderCart } from './cart.js'const cart = []export function addToCart(id) {const item = menu.find((m) => m.id === id)if (!item) returncart.push(item)renderCart(cart)}
Graph
- 1354d06 Add menu pageHEAD → mainorigin/main
- 619eb3b Style the order button
- 5fc44ac Initial commit