Committing is a way in GIT, that adds changes to the repository history and assigns a understandable commit name to it. If by mistake one added a wrong commit message and want to edit it, he can use the below command:
git commit --amend
This command will open your editor and allow you to edit your most recent commit message.
You can also change your commit message directly without opening the editor using the below command:
git commit --amend -m "Enter new commit message"
If you have already pushed the branch then you are editing the commit message that you have to push the branch forcefully. To push the branch forcefully one can use below command: