title: Java GitHub API -org.kohsuke.github Clone repository to Local Machine
body: <p>This might be duplicate, but I don't see any solution or proper documentation or Example. I'm trying to download a Git Hub repository to my local machine. The following is what I tried. I'm using <strong>org.kohsuke.github</strong> API. I don't see any proper method to download to local.</p>
  
  <pre><code>public void cloneRep() {
      String login = "userid";
      String password = "password";
      String rep = "repository";
      String localDir = "/home/myuser/repository/";
      try {
          System.out.println("Connecting...." + login + " : " + password);
          GitHub gitHub = GitHub.connectUsingPassword(login, password);
          boolean isValid = gitHub.isCredentialValid();
          System.out.println("is Valid ? " + isValid);
          if (isValid) {
              GHRepository repository = gitHub.getRepository(rep);
              //how to clone the repository to local directory?
          }
      } catch (Exception e) {
          System.out.println("EXCEPTION....");
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>I know with <strong>org.eclipse.jgit.api.Git</strong> it is possible.</p>
  
  <pre><code>String remoteUrl = new StringBuffer().append("https").append(login)
                  .append(":").append(password).append("@github.com/")
                  .append(login).append("/").append(rep).toString();
  org.eclipse.jgit.api.Git.cloneRepository().setURI(remoteUrl).setDirectory(localDir)
                      .call();
  </code></pre>
  
  <p>But that seems more complex. First I need to do authentication only. And then I need to download to local. I'm not interested to use both. If the API provides a better solution, I can use that.</p>
  
  <p>IS there any solution?</p>