It happens. Hopefully not very often, but accidental commits do happen in GIT.
They are rare enough that we can completely forget how to handle them. So, let's make a little note here of what was just done:
There were only 2 files being intensely revised, so let's make a backup copy of the most recent work:
$ cp file1 ~/safe/ $ cp file2 ~/safe/
reviewing the recent commits we can see where the mistake was made:
$ git log --oneline
the last state before the bad commit was a46e701, so we reset our local repo:
$ git reset --hard a46e701
finally, we push the changes to the remote branch:
$ git push origin HEAD:some_branch --force
and history has been erased!
copy the files back to the working directory and continue coding as if nothing had ever happened!
Now to tidy up our local copy:
$ git checkout some_branch $ git reset --hard origin/some_branch