我使用 JavaGit example 中的代码:
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 交互的库?
最佳答案
根据documentation (我对这个库不太了解),您应该调用 getCommitName()
方法并使用返回的 Ref
对象来获取您想要的信息(我认为SHA1 哈希值或标签)。
关于java - 如何使用JavaGit库获取提交的id?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21676677/