@Override
  public @Nullable GitPushTarget getDefaultTarget(@NotNull GitRepository repository, @NotNull GitPushSource source) {
    GitLocalBranch sourceBranch = source.getBranch();
    if (sourceBranch != null) {
      GitPushTarget pushSpecTarget = getPushTargetIfExist(repository, sourceBranch);
      if (pushSpecTarget != null) return pushSpecTarget;
    }

    GitRemote remote = getDefaultOrFirstRemote(repository.getRemotes());
    if (remote == null) return null;

    if (sourceBranch != null) {
      return makeTargetForNewBranch(repository, remote, sourceBranch.getName());
    }

    GitLocalBranch currentBranch = repository.getCurrentBranch();
    if (currentBranch != null) {
      return makeTargetForNewBranch(repository, remote, currentBranch.getName());
    }

    Set<String> remoteBranches = ContainerUtil.map2SetNotNull(repository.getBranches().getRemoteBranches(), branch ->
      branch.getRemote().equals(remote) ? branch.getNameForRemoteOperations() : null
    );
    String newBranchName = UniqueNameGenerator.generateUniqueName("detached", "", "", remoteBranches);
    return makeTargetForNewBranch(repository, remote, newBranchName);
  }
@Override
  public @Nullable GitPushTarget getDefaultTarget(@NotNull GitRepository repository, @NotNull GitPushSource source)