How to change the last commit message (git commit --amend)
Run git commit --amend -m "New message" to replace the last commit with a corrected one. To add a forgotten change, stage it with git add and run git commit --amend --no-edit to keep the same message.
Step by step
Fix the message of the last commit:
$ git commit --amend -m "Add cookie"Add a forgotten change to the last commit:
$ git add menu.js$ git commit --amend --no-edit
Amend creates a new commit and replaces the old one. Only amend commits you haven't pushed, or your branch will diverge from GitHub's.
Try it in the interactive sandbox →Practice “Fix the message” with a real repository and teammates, right in your browser.