Change the last commit message
Careful: rewrites history
Short answer
Run git commit --amend -m "The right message". The last commit is replaced by one with the new message and the same changes.
Amending makes a new commit that replaces the old one. Fine before you push; after a push it rewrites shared history, so leave the message as it is.
The commands, one by one
- 1
git commit --amend -m "Add muffin recipe"Replaces the latest commit with a copy that has the new message. Nothing that's staged right now is lost: if something is staged, it goes into the amended commit too.
For your own repository: Put your own message between the quotes.