code: public boolean isValidGitRepository(Path folder) {
  
          if (Files.exists(folder) && Files.isDirectory(folder)) {
  
              // If it has been at least initialized
              if (RepositoryCache.FileKey.isGitRepository(folder.toFile(), FS.DETECTED)) {
                  // we are assuming that the clone worked at that time, caller should call hasAtLeastOneReference
                  return true;
              } else {
                  return false;
              }
          } else {
              return false;
          }
      }
docs: Checks if given folder is a git repository
  
  @param folder
  to check
  
  @return true if it is a git repository, false otherwise.