To change the commit message also with repo pushed message:
git rebase -i <hash-of-commit-preceding-the-incorrect-one>- In the editor that opens, change
picktorewordon the line for the incorrect commit. - Save the file and close the editor.
- The editor will open again with the incorrect commit message. Fix it.
- Save the file and close the editor.
- git
push --forceto update GitHub.
Refer: Accidently pushed commit: change git commit message
As one answer in How do I push amended commit to the remote git repo? says:
I actually once pushed with –force to git.git repository and got scolded by Linus BIG TIME. It will create a lot of problems for other people. A simple answer is “don’t do it”.
Notice: rebase has risk!!! It’s better to use for own repo.
PS: To change local commit message, just git amend.