Is there a way to edit a commit message after committing and pushing to GitHub? I see that there is a 'add a note' as well as inline commenting, but no actual editing of a commit message. There is also 'amend commit' in git extensions but that doesn't edit the existing message.
Way to edit a commit message on GitHub
gitgithub
Best Answer
git rebase -i <commit hash you want to change>^
This will open your default editor (usually vi) with a list of commits and actions for each one. By default, the action is
pick
.For any commit you wish to change the message, change
pick
toreword
.Save and quit (in vi:
:wq
).For each such commit, you'll get an editor to edit the commit message. Change it as you see fit, save and quit.
Once you're done editing all the commit messages, you'll return to the command prompt, and have a new tree with the updated messages.
You can now upload them to github by using
git push origin --force
.If you just need to fix your last commit, you can replace steps 1-4 with
git commit --amend
.