To modify the messages of existing unpushed commits, you can use the git commit --amend command. This command allows you to edit the commit message of the most recent commit on your current branch. Here are the steps to follow:

1. Make sure you are on the branch where the commit you want to modify is located.

2. Use the git log command to view the commit history and find the hash of the commit you want to modify.

3. Use the git commit --amend command followed by the -m flag and the new commit message to modify the message. For example, if your original commit message was "Initial commit" and you want to change it to "Updated initial commit", you would run:

git commit --amend -m "Updated initial commit"


4. Save and close the commit message editor.

5. Use the git log command again to verify that the commit message has been modified.

6. If you have multiple unpushed commits that need to be modified, repeat these steps for each commit.

Note that if you have already pushed the commit to a remote repository, you should avoid modifying the commit message as it can cause issues for other contributors who have already pulled the commit. In this case, it's better to add a new commit with the corrected message instead.