How to modify and existing commits which are still not pushed

0 votes
asked Dec 21, 2017 by Hitesh Garg (799 points)  

I have written a wrong message in a commit which is still unpushed to the remote server.
How do I change the commit message in case of latest commit and in case of multiple commits?

1 Answer

0 votes
answered Apr 29, 2018 by Hitesh Garg (799 points)  

The quickest and easiest fix I found is -

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


  • Make sure that there are no stages changes else they will also be added to the commit.
  • These commits are not pushed to the server else you need to force push the commit

git push --force


git push -f

But if this commit already exists in the working copy of others then they will face the issue as amending changes the SHA id and everyone need to resync their system.