GIT doesn't provide a modify history tool but provides measures to do so if the need arises. One can use git rebase in the interactive mode (
git rebase -i) to achieve this with the parent of the last commit that you want to edit as the argument.
This is where git would present a text editor with the commits between this commit and the head listed in the reverse order. You can use "pick", "edit" or "squash" a commit.
squash specifically tells git to apply the commits in question and the commit before them in order and makes you to merge the commit messages.
This is a good way to keep the commit history on the remote cleaner while taking advantages of the version control to checkpoint your local code repo.
git rebase rewrites the history of the commits between parent mentioned above and head. Use with caution! It is not recommended to use this with the code that is already pushed to the remote.