我使用的代码行是:
Git clone = Git.cloneRepository().setURI(URIofRepo).setDirectory(localPath).call();
其中URIofRepo是我的仓库的Github链接, 而localPath是我想要克隆发生的目录。
这个方法非常完美。然而,由于我正在进行的项目不需要克隆来继续工作,我只想让克隆拥有Github仓库的内容,但不包括.git目录。
我也尝试使用以下方法:
File dirToDelete = new File (path + "/.git");
FileUtils.deleteDirectory(dirToDelete);
然而,我遇到了一个IO异常,提示我无法删除文件,具体如下:
Exception in thread "main" java.io.IOException: Unable to delete file: C:\testing\testRepo1.git\objects\pack\pack-7ca7f11688adda065d62f3394d0e055346beff22.pack
git archive
。 - fge