how do I get all commits of a branch with JGit, without changing the working directory?
Unfortunately the JGit docs are not very good ...
In ruby with grit i
You are right, the docs should really be better.
You could use the JGit Log command or use a library like gitective which makes iterating over commits easy. You can look at the source to learn more about JGit.
Other (more complicated) ways are described in this SO-question.