Way to edit a commit message on GitHub

gitgithub

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.

Best Answer

  1. git rebase -i <commit hash you want to change>^

    This will open your default editor (usually ) with a list of commits and actions for each one. By default, the action is pick.

  2. For any commit you wish to change the message, change pick to reword.

  3. Save and quit (in vi: :wq).

  4. 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.

  5. 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.

Related Question