Jgit traverse content of a commit from specific branch

How can I traverse with jgit all content of an specific commit from an specific branch?

ObjectId commitId = repository.resolve(currentCommit.getCommitHash());
RevWalk revWalk = new RevWalk(repository);
RevCommit commit = revWalk.parseCommit(commitId);
RevTree tree = commit.getTree();
TreeWalk treeWalk = new TreeWalk(repository);
treeWalk.addTree(tree);
treeWalk.setRecursive(true);
treeWalk.setFilter(PathFilter.create(currentPath));
if (!treeWalk.next()) {
    throw new IllegalStateException(
            "Did not find expected file README.md");
}

This code retrieve me a special file from the commit but I want traverse all content of an commit.

  • Upgrading git from the source repository in Ubuntu
  • What exactly does the ReCommit feature in TortoiseGit do?
  • Cannot use “git commit -a”
  • git push doesn't working?
  • .gitignore is whitespace sensitive?
  • How can I (simply) undo changes to a file in GIT?
  • What does git filter-branch with no arguments do?
  • Git status reports untracked on tracked files
  • Downloading a source from a git repository using eclipse?
  • msysgit on windows — what should I be aware of, if any?
  • git pull remote branch cannot find remote ref
  • Git. Remote HEAD is ambiguous
  • One Solution collect form web for “Jgit traverse content of a commit from specific branch”

    See this answer, it lists files and folders. You can use setRecursive(true) and leave off the isSubtree branch when you are just interested in file paths.

    Git Baby is a git and github fan, let's start git clone.