brewly — Ch.4 · Undo a commit, keep the work
Exercise 2 of 9
Before you start
Moving the branch back
git reset <commit> moves your branch to another commit. HEAD~1 means "one commit before where I am".
The mode decides what happens to the changes you leave behind. --soft keeps them staged. The default, --mixed, keeps them in your files but unstaged. Neither loses work.
Like amending, this rewrites history, so only do it with commits you have not pushed.
- git reset HEAD~1
- undo the last commit; changes stay in your files
- git reset --soft HEAD~1
- undo it; changes stay staged
- git status
- see what is back
- git add <file>
- stage one part
- git commit -m "What you did"
- commit it
You can reopen this any time with “Lesson”.
# BrewlyOrder coffee ahead.## Team- Maya (lead)- Alex (frontend)
Graph
- cbec2b9 WIP stuffHEAD → main
- 1354d06 Add menu pageorigin/main
- 619eb3b Style the order button
- 5fc44ac Initial commit