JGit 不克隆所有分支

时间:2021-01-07 13:03:54

标签: java spring jgit

JGit 不允许我将所有分支克隆到本地。

这是我克隆 repo 的代码。

git = Git.cloneRepository().setURI(repositoryURL)
    .setCredentialsProvider(cp)
    .setDirectory(file)
    .setCloneAllBranches(true)
    .call();

在克隆之后,我正在使用下面的代码打印本地+远程分支的列表

System.out.println("Showing local branches...");
List<Ref> call = git.branchList().call();
for (Ref ref : call) {
    System.out.println("Branch: " + ref.getName());
}

System.out.println("Now including remote branches:");
call = git.branchList().setListMode(ListMode.ALL).call();
for (Ref ref : call) {
    System.out.println("Branch: " + ref.getName());
}

这是我得到的输出..... 如您所见,本地分支仅显示主分支。

Showing local branches...

Branch: refs/heads/master

Now including remote branches:

Branch: refs/heads/master
Branch: refs/remotes/origin/docker
Branch: refs/remotes/origin/master
Branch: refs/remotes/origin/release
Branch: refs/remotes/origin/stage

我是否必须为每个远程分支手动发出分支创建命令?

0 个答案:

没有答案
相关问题