def do_clean_all(git_repo)
      old_initial_directory = git_repo.repo_dir
      clean_all_options = {
        :directories => true,
        :gitignored  => true,
        :submodules  => true
      }
      relative_paths = [
        '.',
        git_repo.submodule_paths(:recursive => true)
      ].flatten
      relative_paths.each do |relative_path|
        subdir_path = ::File.expand_path(::File.join(@repo_dir, relative_path))
        if ::File.directory?(subdir_path)
          # reuse shell with any watch parameters already set but vary the
          # initial directory for each submodule.
          git_repo.shell.initial_directory = subdir_path
          git_repo.clean_all(clean_all_options)
        end
      end
      true
    rescue ::RightGit::RightGitError => e
      @logger.note_warning(e.message)
      false
    ensure
      git_repo.shell.initial_directory = old_initial_directory
    end
def do_clean_all(git_repo)
      old_initial_directory = git_repo.repo_dir
      clean_all_options = {
        :directories => true,
        :gitignored  => true,
        :submodules  => true
      }
      relative_paths = [
        '.',
        git_repo.submodule_paths(:recursive => true)
      ].flatten
      relative_paths.each do |relative_path|
        subdir_path = ::File.expand_path(::File.join(@repo_dir, relative_path))
        if ::File.directory?(subdir_path)
          # reuse shell with any watch parameters already set but vary the
          # initial directory for each submodule.
          git_repo.shell.initial_directory = subdir_path
          git_repo.clean_all(clean_all_options)
        end
      end
      true
    rescue ::RightGit::RightGitError => e
      @logger.note_warning(e.message)
      false
    ensure
      git_repo.shell.initial_directory = old_initial_directory
    end
Cleans anything that is currently untracked in the repo directory and
 any submodules. the idea is to prevent untracked items interfering with
 the normal behavior that would result if checkout were always to a clean
 directory. just switching between branches and updating submodules can
 leave untracked artifacts that affect behavior.