Amending the commit message :-

git commit --amend

This command will open your editor, You can change the commit message of the most recent commit.Commit message can directly change from command line using below command :-

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

If code already pushed to remote branch then you’ll need to force push the commit using following command :-

git push <remote> <branch> --force

# Or

git push <remote> <branch> -f 

Warning: force-pushing will overwrite the remote branch with the state of your local one.
Amending commits will update the SHA IDs which poses a problem if other developer have copies of old commit .