Modify the last commit message in the local copy
There are cases when you must alter the last commit message. This can be done by typing the following command in the command line:
git commit --amend -m "My awesome new message"
Modify the last commit message in the remote repository
First, you must modify the local commit message, as it is described in the previous section. Next, you can push the local state of the branch to the remote repository.
git push --force origin <branch_name>
Such a change needs coordination within the team, otherwise, you can overwrite their commits with the state of your local copy!
Demonstration
The video below demonstrates the described commands above: