private void deleteFileTree(final Path root, final boolean keepGitStuff)
            throws IOException {

        Files.walkFileTree(root, new SimpleFileVisitor<>() {
            @Override
            public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {

                // Ignore any .git subtree
                if (keepGitStuff && dir.endsWith(GIT_REPO_DIRNAME)) {
                    return FileVisitResult.SKIP_SUBTREE;
                } else {
                    return FileVisitResult.CONTINUE;
                }
            }

            @Override
            public FileVisitResult visitFile(Path p, BasicFileAttributes attrs)
                    throws IOException {

                // Don't delete README files
                if (!(keepGitStuff && p.endsWith(GIT_README_MD))) {
                    Files.delete(p);
                }
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult postVisitDirectory(Path dir, IOException ex)
                    throws IOException {

                // Don't delete the root dir or the .git dir
                if (!dir.equals(root) && !(keepGitStuff && dir.endsWith(GIT_REPO_DIRNAME))) {
                    Files.delete(dir);
                }
                return FileVisitResult.CONTINUE;
            }
        });
    }
Deletes a file tree recursively. Does not delete any .git
directories nor any README.md.

@param root         Delete everything under this directory. Must not be null.
@param keepGitStuff If true then keep Git key files - .git/, README.md.
                    If false then delete everything.
@throws IOException if something goes wrong.
stroom-gitrepo/stroom-gitrepo-impl/src/main/java/stroom/gitrepo/impl/GitRepoStorageService.java