3

I want to perform sparse checkout in GIT i.e. checking out a portion of working copy from repository.How can I do this by a Java code.Pls suggest.

Alok
  • 929
  • 10
  • 26
  • 1
    see http://stackoverflow.com/questions/14407461/how-do-i-implement-sparse-checkout-in-jgit – centic Aug 28 '13 at 05:39

2 Answers2

2

Based on @rüdiger-herrmann's answer:

String url = "https://github.com/renaud/solr_noLenghNormSimilarity";
String hash = "802558f58add3a1f5b33f04254194bd7cd59b27f";
String subPath = "src/org";
String dest = "myclone";

File localPath = new File(dest);

Git gitRepo = Git.cloneRepository().setURI(url).setDirectory(localPath).setNoCheckout(true).call();
gitRepo.checkout().setStartPoint(hash).addPath(subPath).call();
gitRepo.getRepository().close();
Community
  • 1
  • 1
Renaud
  • 16,073
  • 6
  • 81
  • 79
1

Currently the JGit library (as of 3.0.0) doesn't support sparse checkouts.

AlBlue
  • 23,254
  • 14
  • 71
  • 91