brewly — Ch.1 · Take it back
Exercise 7 of 11
Before you start
Taking things back
Two different jobs. Unstaging removes a file from the next commit but keeps your edit. Discarding throws the edit away.
Careful: git cannot bring back a discarded change that was never committed or staged.
- git status
- see what is staged and what is not. It also suggests these commands
- git restore --staged <file>
- unstage: keep the edit, leave it out of the commit
- git restore <file>
- discard: throw the edit away
- git commit -m "What you did"
- commit what is still staged
You can reopen this any time with “Lesson”.
body {background: hotpink;font-family: system-ui, sans-serif;margin: 2rem;}
Graph
- 1354d06 Add menu pageHEAD → mainorigin/main
- 619eb3b Style the order button
- 5fc44ac Initial commit