我使用JavaGit示例中的以下代码:
File repositoryDirectory = new File("Library\\build\\jar\\");
DotGit dotGit = DotGit.getInstance(repositoryDirectory);
// Print commit messages of the current branch
for (Commit c : dotGit.getLog()) {
System.out.println(c.getMessage());
}
我如何以这种方式获取提交的ID?还是更适合与git交互的库?
根据文档(我对这个库不是很了解),您应该调用该getCommitName()
方法并使用返回的Ref
对象来获取所需的信息(我认为是SHA1哈希或标记)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句