If you just want to edit the latest commit, use:
git commit --amend
or
git commit --amend -m 'one line message'
But if you want to edit several commits in a row, you should use rebasing instead:
git rebase -i

In a file, like the one above, write edit/e
or one of the other options, and hit save and exit.
Now you'll be at the first wrong commit. Make changes in the files, and they'll be automatically staged for you. Type
git commit --amend
Save and exit that and type
git rebase --continue
to move to next selection until finished with all your selections.
Note that these things change all your SHA hashes after that particular commit.