Search code examples
gitgit-pushgit-commit

Edit an incorrect commit message in Git that has already been pushed


I did a Git commit and push, but wrote the totally wrong thing in the comment.

How do I change the comment? I have already pushed the commit to the remote.


Solution

  • git commit --amend will allow you to edit the commit message.

    If you already pushed that commit, you need to run git push --force. Only do that if you are sure nobody pulled it yet!

    If people pulled the commit from your repo, simply leave the message as it is.