How do I undo the most recent local commits in Git?

I accidentally committed the wrong files to Git but didn’t push the commit to the server yet. How can I undo those commits from the local repository? The only way seems to be to copy the edits in some kind of GUI text editor, then wipe the whole local clone, then re-clone the repository, then … Read more