Remove a local commit
Remove your latest local commit and keep the changes you have made. The changes will still appear the same as before you staged them.
git reset --soft HEAD^
HEAD^
means go back one commit from where HEAD
is now.
Remove a pushed commit
If you already have pushed your commit to the repo, the safest way to remove it is probably reverting it. Find the commit hash of the commit you want to revert and type the following.
git revert <commit-hash>
This will create a completely new commit that will undo all the changes in the selected commit. Just push it up to remote and you are good to go.