How to “cat” a file in JGit?
问题 A while back I was looking for an embeddable distributed version control system in Java, and I think I have found it in JGit, which is a pure Java implementation of git. However, there is not much in the way of sample code or tutorials. How can I use JGit to retrieve the HEAD version of a certain file (just like svn cat or hg cat whould do)? I suppose this involves some rev-tree-walking and am looking for a code sample. 回答1: Unfortunately Thilo's answer does not work with the latest JGit API.