In my local repo I have one commit with an incorrect commit message.
I've already published the incorrect commit message with git push
.
Now the remote repo (which is GitHub-hosted) has the incorrect commit message, too.
I've already tried git commit --amend
, but found that it will not work for me in this situation because I've made additional commits since the incorrect one.
How would you fix this situation?
Easiest solution (but please read this whole answer before doing this):
git rebase -i <hash-of-commit-preceding-the-incorrect-one>
pick
toreword
on the line for the incorrect commit.git push --force
to update GitHub.This will mean you will be publishing a modified version of a previously published repository. If anyone pulled or fetched from your repo between when you made the mistake with the incorrect commit message, and when you fixed it, then they will experience some difficulties later. So be sure you can accept this consequence before trying this.