I want traverse my git repo but only the HEAD commit including the remote branches. I have only local master branch and a lot of remote branches. I can traverse my actually working directory like.
Ref head = repository.getRef("HEAD");
RevWalk walk = new RevWalk(repository);
RevCommit commit = walk.parseCommit(head.getObjectId());
RevTree tree = commit.getTree();
TreeWalk treeWalk = new TreeWalk(repository);
treeWalk.addTree(tree);
treeWalk.setRecursive(true);
while (treeWalk.next()) {
System.out(treeWalk.getPathString())
}
repository.close();
But this code only traverse the actual working directory. Afterwards i want read the files in the head commit. How i perform the reading and traversing the branches?