Changing a git commit message after I have pushed it to the server?

How to change a wrong git commit message after I have pushed it to the server?

If the remote repository is shared with others, it is better to let the wrong git commit message there.

If you use the repository by your own and you are sure that no one else has pulled your latest commit:

First, change the local commit message:

git commit --amend -m "New commit message"

Then, force pushing again:

git push -f

Again, this operation is dangerous. Do it only if you know what you are doing.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *