brewly — Ch.4 · Fix the commit you just made
Exercise 1 of 9
Before you start
Replacing the last commit
git commit --amend makes a new commit that replaces the last one. It takes whatever is staged now, plus everything the old commit had.
Without more options git opens the editor with the old message. -m gives a new message instead, and --no-edit keeps the old one.
The replaced commit gets a new id. Only amend commits you have not pushed yet.
- git status
- what was left out of the commit?
- git add <file>
- stage it
- git commit --amend
- replace the last commit and edit its message
- git commit --amend -m "New message"
- replace it with a new message
- git commit --amend --no-edit
- replace it, keeping the message
- git log --oneline
- check the result
You can reopen this any time with “Lesson”.
# BrewlyOrder coffee ahead.## Team- Maya (lead)- Alex (frontend)
Graph
- 2ba0338 Add alergen listHEAD → main
- 1354d06 Add menu pageorigin/main
- 619eb3b Style the order button
- 5fc44ac Initial commit