To modify unpushed commit messages then –amend flag will be useful to modify the unpushed commits. Follow the below code snippets. To modify the commit message on command line then use:
git commit --amend -m "New commit message"
To modify the commit in the default editor then use:
git commit --amend
Also Read:
How to rename Local Git Branch