Show the last 4 commits in a text editor and find the commit you want to modify,
git rebase -i @~4
Remember that @ is shorthand for HEAD, and ~ is the commit before the specified commit.
Now, replace pick to e (edit) and save and close the file. Git rewinds that commit, allowing you to either:
- use the command, git commit --amend to make changes, or
- use the command, git reset @~ to discard the last commit, but not the changes to the files
The second one is useful for doing more complex stuff like splitting into multiple commits.
After that run the command, git rebase --continue, and then Git will replay the subsequent changes on top of your modified commit. You may be asked to fix some merge conflicts.
For more information please go through the following tutorial to get more info about git: