How to revert uncommitted changes including files and folders?

If you want to revert the changes only in the current working directory, use

git checkout -- .

And before that, you can list the files that will be reverted without actually making any action, just to check what will happen, with:

git checkout --

You can run these two commands:

# Revert changes to modified files.
git reset --hard

# Remove all untracked files and directories.
# '-f' is force, '-d' is remove directories.
git clean -fd

Use "git checkout -- ..." to discard changes in working directory

git checkout -- app/views/posts/index.html.erb

or

git checkout -- *

removes all changes made to unstaged files in git status eg

modified:    app/controllers/posts.rb
modified:    app/views/posts/index.html.erb