Git - Undo All Uncommitted Changes

Lets say you have some not yet committed changes and you want to undo everything.

In particular you want to delete all newly created files and folders and restore all modified or deleted.

In short you need to revert all changes back to the last commit.

If you are sure that you will never need the uncommitted changes, then run the below commands.

Reset All Changes

Unstage all files and directories you might have staged with 'git add':

$ git reset --hard HEAD

Remove Unstaged Files and Directories

It is always a good idea firstly to run 'git clean' with '-n' option to preview files and directories that are going to be deleted to ensure you don't need them anymore.
Preview and then remove untracked files and directories:

$ git clean -nd
$ git clean -fd

Attention! Execution of the below command is basically equivalent to fresh 'git clone' from original source. It will REMOVE ALL LOCAL UNTRACKED FILES INCLUDING IGNORED BY GIT through '.gitignore'.
Preview and then remove ALL untracked files and directories:

$ git clean -ndx
$ git clean -fdx