Fix the message of the last commit

Description: The last commit message is “Add contcat page”. Change it to “Add contact page”.

Hint:

  • Use git commit --amend -m.

Solution

Terminal output

$ git log –oneline
0e698a4 (HEAD -> main) Add contcat page
$ git commit –amend -m "Add contact page"
[main 6e54967] Add contact page
Date: Sat Jan 10 10:42:00 2026 +0000
1 file changed, 1 insertion(+)
create mode 100644 contact.html
$ git log –oneline
6e54967 (HEAD -> main) Add contact page

How it works

  • Amend replaces the last commit with a new commit, so the hash changes.
  • Do not amend a commit that is already pushed and used by others.

Read Git Commit Amend.


Learn more about the similar topics:
Tutorials
Git Restore
Git Commit Amend
Git Reset
Git Revert
Git Stash
Git Reflog
Exercises & Assignments
Discard the changes of a file
Undo the last commit but keep the changes
Revert a commit with git revert
Fix the message of the last commit
Stash your changes and bring them back
Recover a deleted branch with git reflog
Interview Questions & Answers
What is git revert?
How to undo last commit using git reset?
What is the difference between git reset and git revert?
What is the difference between soft, mixed and hard reset in Git?
What is git stash and when do you use it?
How do you change the last commit message in Git?
How do you squash commits in Git?