how to change commit message git code example

Example 1: change git commit message

git commit --amend -m "New commit message"

Example 2: amend last commit message

$ git commit --amend -m "New and correct message"

Example 3: edit last commit message

git commit --amend -m "New commit message."

Example 4: git amend

git commit --amend

Example 5: change commit message

git commit --amend
// press enter, editor would open

Example 6: how to edit old commit message in git

# Displays a list of the last 3 commits on the current branch
$ git rebase -i HEAD~3