code: public void cloneBranch(String branch) throws Exception {
          CloneCommand cloneCommand = Git.cloneRepository()
                  .setURI(repositoryUrl)
                  .setDirectory(localRepo.getDirectory().getParentFile())
                  .setBranchesToClone(Arrays.asList(branch))
                  .setCloneAllBranches(false)
                  .setBranch(branch);
          if (credentialsProvider != null)
              cloneCommand.setCredentialsProvider(credentialsProvider);
          Git git = cloneCommand.call();
          git.getRepository().close();
          git.close();
      }
docs: Different from cloneRepo in that will clone only a single branch.
  For quicker clone of specific branch/tag.