Let say you stage all your Git changes and then commit them.
git add --all
git commit -m "Edit REDME.md"
There's a typo on REDME — should read README — and we want to "amend" this error.
git commit --amend
The commit --amend command lets you edit the commit message in the vim editor.
You can also change the message by specifying the new message in the command line with the -m argument.
git commit --amend -m "Edit README.md"
As the commit message is part of the commit itself, editing the message alters the commit hash, which means that if you've already pushed a commit to a remote, the remote won't let you push the new edit directly. But you can force that to happen.
git push --force branch-name