If you only want to change your last message you should use the --only
flag or its shortcut -o
with commit --amend
:
git commit --amend -o -m "New commit message"
This ensures that you don't accidentally enhance your commit with staged stuff. Of course it's best to have a proper $EDITOR
configuration. Then you can leave the -m
option out, and Git will pre-fill the commit message with the old one. In this way it can be easily edited.