### How To
```
git reset --hard HEAD
git clean -f -d
git checkout master
git fetch origin master
git reset --hard origin/master
git pull
git status
```
---
[StackOverflow](https://stackoverflow.com/a/4327720/6412747):
You have to use `git clean -f -d` to get rid of untracked files and directories in your working copy.
If you need to reset the whole repository to master including all git submodules, run this script:
```
git reset --hard HEAD
git clean -f -d
git checkout master
git fetch origin master
git reset --hard origin/master
git pull
git submodule update
git submodule update --init --recursive
git submodule foreach git reset --hard HEAD
git submodule foreach git clean -f -d
git submodule foreach git submodule update --init --recursive
git submodule foreach git fetch
git submodule foreach git pull
git status
```