git commit --amend -m "your new message"
To amend previous commit make the changes you want and stage those changes, and then use
git commit --amend
to amend previous commit, and keep the same log message use
git commit --amend -C HEAD
to fix the previous commit by removing it entirely use
git reset --hard HEAD^
If you want to edit more than one commit message use
git rebase -i HEAD~COMMIT_COUNT
Do not forget to replace COMMIT_COUNT with number of commits that you want to edit.
This command launches editor, mark the first commit (the one that you want to change) as “edit” instead of “pick”, then save and exit your editor.
make the change you want to commit then:
git commit --amend git rebase --continue
git commit --amend is the way to overwrite the last commit. One note: if you would like to also overwrite the files, the command would be
git commit -a --amend -m "My new commit message"