JGit:遍历仓库时如何获取分支 [英] JGit : How to get Branch when traversing repos
本文介绍了JGit:遍历仓库时如何获取分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
缺少的JGit文档似乎没有说明在使用RevWalk时如何使用/检测分支。
这个问题说的差不多。
所以我的问题是:如何从RevCommit获取分支名称/ ID?还是我该如何指定要先遍历的分支?
解决方案
找到了一种更好的方法,可以通过循环分支来实现。 / p>
我通过调用
for(引用分支: git.branchList()。call()){
git.checkout()。setName(branch.getName())。call();
//然后像往常一样走开。
}
The lacking JGit docs dont seem to say anything about how to use/detect branches while using a RevWalk.
This question says pretty much the same thing.
So my question is: How do I get the branch name/id from a RevCommit? Or how do I specify which branch to traverse before hand?
解决方案
Found out a better way to do it by looping branches.
I looped over the branches by calling
for (Ref branch : git.branchList().call()){
git.checkout().setName(branch.getName()).call();
// Then just revwalk as normal.
}
这篇关于JGit:遍历仓库时如何获取分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文