code: public boolean isRemoteBranch(final Git git, final String branch, final String remote) {
          try {
              final List<Ref> refs = git.branchList()
                  .setListMode(ListBranchCommand.ListMode.REMOTE).call();
  
              final String remoteBranch = remote + "/" + branch;
              return refs.stream().anyMatch(ref -> ref.getName().endsWith(remoteBranch));
          } catch (GitAPIException e) {
              throw new IllegalStateException(e);
          }
      }
docs: Checks if given branch is remote.
  
  @param git
  instance.
  @param branch
  to check.
  @param remote
  name.
  
  @return True if it is remote, false otherwise.