How can I edit my last commit message?
Changing the message in your last commit
You may find you've just created a new commit, but you want to modify the message.
Simply navigate to your project's directory via the command prompt, and type the following command, followed by the enter key:
$ git commit --amend
You'll be redirected to your text editor to edit the message. The message will be at the very top of the screen; simply edit it:
New commit message
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Thu May 16 11:47:16 2019 +0100
#
# On branch my_new_branch
# Your branch is up to date with 'origin/my_new_branch'.
#
# Changes to be committed:
# new file: newfile
#
Then, press ctrl + x
followed by y
and the enter key.
[my_new_branch b356ae0] New commit message
Date: Thu May 16 11:47:16 2019 +0100
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 newfile