Change the last commit message
I made a typo in the message of my last commit.
The problem
I made a typo in the message of my last commit.
How the practice repository looked before
## main
48620fe Add line two 8f690c6 Add notes
The fix
[main d1ad928] Add the second line of notes Date: Sun Jan 25 10:00:00 2026 +0000 1 file changed, 1 insertion(+)
Check the result
d1ad928 Add the second line of notes 8f690c6 Add notes
Why this works
--amend replaces the last commit with a new one that has the new message. The commit gets a new hash, because the message is part of what the hash is made from.
If this is not quite your case
If you run git commit --amend without -m, Git opens your editor with the old message. Using -m on the command line avoids the editor. If the commit is already pushed, amending means you must force-push, which changes history for others; for a shared branch leave the message as it is and explain in the next commit.
Be careful: Do not amend a commit that others may already have pulled. It rewrites history.
This is an independent guide. It is not connected with the Git project, GitHub, GitLab or any company named here. Every command below was run on 14 November 2026 with the real program (git version 2.56.0.windows.4) in a new empty practice repository; the output shown is what it printed. Facts about options were read in the official Git documentation on 14 November 2026.