Hi all,
I'm currently try to clone only the master branch of a huge repository.
Therefore I tried two different approaches:
Git.cloneRepository().setURI("repositoryurl.git").setDirectory(new File("localFolder")).setCredentialsProvider(new UsernamePasswordCredentialsProvider(username,password)).setCloneAllBranches(false).setBranch("master");
I thought, this is the same as git clone -b master --single-branch repositoryurl.git localFolder
, but the first one clones the whole repository including all branches. The nativ git command works fine.
The second approach was:
Git.cloneRepository().setURI("repositoryurl.git").setDirectory(new File("localFolder")).setCredentialsProvider(new UsernamePasswordCredentialsProvider(username,password)).setCloneAllBranches(false).setBranchesToClone(Arrays.asList("refs/heads/master"));
I also tried a lot of mixtures of the parameters, but jGit always cloned the whole repository.
I tried it with jGit 4.4 and jGit 4.6.
Does somebody know, how to clone a single branch with jGit?
Best,
Arne