How to revert uncommitted changes including files and folders?

MEM picture MEM · Apr 27, 2011 · Viewed 800.3k times · Source

Is there a git command to revert all uncommitted changes in a working tree and index and to also remove newly created files and folders?

Answer

htanata picture htanata · Apr 28, 2011

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