I need to clone a git repository in java. I am using jGit.
The line of code used:
Git clone = Git.cloneRepository().setURI(URIofRepo).setDirectory(localPath).call();
Where is URIofRepo: the github link to my repo as well as Where localPath: the directory where I want the clone to happen.
It works great. However, since using the project that I am running does not require a clone to continue working, I just want the clone to have the contents of the github repository WITHOUT the .git directory.
I also tried using the following:
File dirToDelete = new File (path + "/.git"); FileUtils.deleteDirectory(dirToDelete);
However, I have an IO exception saying that I cannot delete the file as follows:
An exception in the stream "main" java.io.IOException: cannot delete the file: C: \ testing \ testRepo1.git \ Objects \ package \ pack-7ca7f11688adda065d62f3394d0e055346beff22.pack
source share