我现有的代码
//clone repo
File localPath = File.createTempFile("TestGitRepository", "");
localPath.delete();
private Repository repo;
Git git = Git.cloneRepository()
.setCredentialsProvider(credentials)
.setURI(url)
.setBranch(branch)
.setDirectory(localPath)
.call();
repo = git.getRepository();
//get commit by using cloned repo
try (Git git = new Git(repo)) {
Iterable<RevCommit> logs = git.log().call();
for (RevCommit rev : logs) {
System.out.println("Commit: " + rev + ", name: " + rev.getName() + ", id: " + rev.getId().getName());
}
} catch (Exception e) {
System.out.println("Exception: {}"+e);
}
我能够通过克隆存储库来获取提交列表,我想避免克隆存储库。如果有办法,请分享一些链接,如果需要,还建议我额外的库。
在这里你可以简单地使用git命令获取git日志而不需要git副本,
git log -- <git http url
例如git log -- [email protected]/twitter/bootstrap.git