private @Nullable Map<GitRepository, GitBranchPair> checkTrackedBranchesConfiguration() {
    LOG.info("checking tracked branch configuration...");

    Map<GitRepository, GitLocalBranch> currentBranches = new LinkedHashMap<>();
    List<GitRepository> detachedHeads = new ArrayList<>();
    for (GitRepository repository : myRepositories) {
      if (mySubmodulesInDetachedHead.containsKey(repository)) {
        LOG.debug("Repository " + repository + " is a submodule in detached HEAD state, not checking its tracked branch");
        continue;
      }

      GitLocalBranch branch = repository.getCurrentBranch();
      if (branch != null) {
        currentBranches.put(repository, branch);
      }
      else {
        detachedHeads.add(repository);
        LOG.info(String.format("skipping update of [%s] (detached HEAD)", getShortRepositoryName(repository)));
      }
    }

    if (!detachedHeads.isEmpty() && (currentBranches.isEmpty() || isSyncControl())) {
      notifyDetachedHeadError(detachedHeads.get(0));
      return null;
    }
    else {
      for (GitRepository repo : detachedHeads) {
        mySkippedRoots.put(repo, GitBundle.message("update.skip.root.reason.detached.head"));
      }
    }

    Map<GitRepository, GitBranchPair> trackedBranches = new LinkedHashMap<>();
    List<GitRepository> noTrackedBranch = new ArrayList<>();
    for (GitRepository repository: currentBranches.keySet()) {
      GitLocalBranch branch = currentBranches.get(repository);
      GitBranchTrackInfo trackInfo = GitBranchUtil.getTrackInfoForBranch(repository, branch);
      if (trackInfo != null) {
        trackedBranches.put(repository, new GitBranchPair(branch, trackInfo.getRemoteBranch()));
      }
      else {
        noTrackedBranch.add(repository);
        LOG.info(String.format("skipping update of [%s] (no tracked branch for current branch [%s])",
                               getShortRepositoryName(repository), branch));
      }
    }

    if (myCheckForTrackedBranchExistence &&
        !noTrackedBranch.isEmpty() && (trackedBranches.isEmpty() || isSyncControl())) {
      GitRepository repo = noTrackedBranch.get(0);
      notifyNoTrackedBranchError(repo, currentBranches.get(repo));
      return null;
    }
    else {
      for (GitRepository repo : noTrackedBranch) {
        mySkippedRoots.put(repo, GitBundle.message("update.skip.root.reason.no.tracked.branch"));
      }
    }

    return trackedBranches;
  }
private @Nullable Map<GitRepository, GitBranchPair> checkTrackedBranchesConfiguration()