brewly — Ch.1 · Commit only what belongs
Exercise 6 of 11
Before you start
Small, focused commits
A commit should contain one change that belongs together. The staging area lets you choose what goes in: only staged changes are committed.
Debugging lines such as console.log are for you, not for the team. Leave them unstaged.
- git diff
- read all changes that are not staged yet
- git add <file>
- stage one file only, for example
git add src/app.js - git add .
- stage everything in the folder. Not what you want when something should stay out
- git status
- check what is staged before committing
- git commit -m "What you did"
- save only the staged changes
You can reopen this any time with “Lesson”.
export function renderCart(cart) {console.log('DEBUG', cart)const total = cart.reduce((sum, item) => sum + item.price, 0)document.querySelector('#total').textContent = total.toFixed(2)}
Graph
- 1354d06 Add menu pageHEAD → mainorigin/main
- 619eb3b Style the order button
- 5fc44ac Initial commit