Changing git commit message after push

Changing git commit message after push

You know the feeling when you just pushed a commit to the remote and realize you've got a typo or some information missing in your commit message? There is a fix for that.

Not for the feeling itself, but at least for the message. You can update it the following way:

To update the message run the following

git commit --amend

To push the changes to the branch (master) on the remote repository (origin) use:

git push --force-with-lease origin master

You can also use --force but this will overwrite whatever is on your repository. With --force-with-lease you will get an error when there are new commits on the upstream. This way you can prevent overwriting work of others and can rebase the new changes before trying it again.