Git Amend
To amend is to replace the last commit with a new one, using git commit --amend. You can fix the message, add changes you forgot, or both.
The amended commit gets a new hash. Only amend commits you have not pushed yet.
Fix a typo in the last commit message
git log --oneline -1
e647d22 Add a thank yuo line
git commit --amend -m "Add a thank you line"
[main 449b168] Add a thank you line
Date: Thu Nov 5 10:58:05 2026 +0100
1 file changed, 1 insertion(+)
Add a forgotten change
Stage the change, then amend with --no-edit to keep the message:
git add index.html
git commit --amend --no-edit
[main bf9f310] Add a thank you line
Date: Thu Nov 5 10:58:05 2026 +0100
1 file changed, 2 insertions(+)