A couple of commands that I'm always using that are super useful unless you have already pushed:

git commit --amend - changes your last commit message


git rebase -i yourcommithash~1 - changes some other commit message


git commit --amend can be used on its own or if you don't want to get dropped into vim / emacs (whatever $GIT_EDITOR is set to): git commit --amend -m "your new message"

git rebase -i yourcommithash~1 will open your editor with the commit you want to rename and the commits before it. Change pick to r, save and exit (don't rename the commit in the list of commits), rename the commit then and save and exit. Done.

This is only safe if you haven't pushed because other Developers may have pulled your old commits and you're rewriting history by doing this (if it's just you working on a project and you know what you're doing, you can pass the -f to git push if you have already pushed to ignore git's no push warning).