如何使用JGit获取存储库中的所有分支?我们来看一个示例存储库.我们可以看到,它有5个分支.
在这里我找到了这个例子:
int c = 0;
List<Ref> call = new Git(repository).branchList().call();
for (Ref ref : call) {
System.out.println("Branch: " + ref + " " + ref.getName() + " "
+ ref.getObjectId().getName());
c++;
}
System.out.println("Number of branches: " + c);
Run Code Online (Sandbox Code Playgroud)
但我得到的只是:
Branch: Ref[refs/heads/master=d766675da9e6bf72f09f320a92b48fa529ffefdc] refs/heads/master d766675da9e6bf72f09f320a92b48fa529ffefdc
Number of branches: 1
Branch: master
Run Code Online (Sandbox Code Playgroud)