The git commit --amend command is a convenient way to modify the most recent commit. It lets you combine staged changes with the previous commit instead of creating an entirely new commit. It can also be used to simply edit the previous commit message without changing its snapshot.
$ git commit --amend
It will open your editor, allowing you to change the commit message of the most recent commit. Additionally, you can set the commit message directly in the command line.
$ git commit --amend -m "New commit message"