简体   繁体   中英

How to do sparse checkout in git using Java

我想在GIT中执行稀疏检出,即从存储库检出一部分工作副本。如何通过Java代码执行此操作。建议。

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();

当前,JGit库(从3.0.0开始)不支持稀疏签出。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM