1. Local commit, not pushed to remote warehouse
You can git reset --soft <commit_id>, commit_id is a version to be rolled back to
Then make changes, and then commit,
If you need to completely discard the file changes and go back to a certain version, just git reset --hard
2. Undo the commit submitted to the remote
git revert <commit_id>
git push --force (specify branch depending on the situation)