title: How to clone a single file with jGit?
body: <p>I am working with jGit in Java and I have managed to clone an entire repository. But I can not find a way to download a single file inside a repository. I have tried:</p>
  
  <ul>
  <li>Change the URL specifying the path of the file.</li>
  <li>Change the URL by specifying a subdirectory.</li>
  </ul>
  
  <p>Neither of them worked.</p>
  
  <p>My code (clone whole repository) is as follows:</p>
  
  <pre><code>public File cloneRepository(String url, String path) throws GitAPIException {
  
      File download = new File (path);
      if (download.exists()){
          System.out.println("Error");
          return null;
      }
      else{
          CloneCommand clone = Git.cloneRepository()      
                  .setURI(url)
                  .setDirectory(download);
          try (Git repositorio = clone.call()) {
              return repositorio.getRepository().getWorkTree();
          }
      }
  }
  </code></pre>
  
  <p>How could it be changed to download a single file?</p>