In GitHub Desktop you can just right click the commit and revert it, which will create a new commit that undoes the changes.
The accidental commit will still be in your history (which may be an issue if, for instance, you've accidentally commited an API key or password) but the code will be reverted.
This is the simplest and easiest option, the accepted answer is more comprehensive.