I try to read the latest version of a file from the GIT server. Somehow this picks up the wrong version. Could you please help?
public void copyFileToOutputStream(Repository repository, String filePath, OutputStream os) throws Exception {
        try (TreeWalk treeWalk = new TreeWalk( repository) ) {
            RevCommit revCommit = repository.parseCommit(repository.resolve("origin/head"))
            treeWalk.addTree(revCommit.getTree());
            treeWalk.setRecursive(true);
            treeWalk.setFilter(PathFilter.create(filePath));
            if (!treeWalk.next()) {
                throw new IllegalStateException("Did not find expected file '" + filePath + "'");
            }
            final ObjectId objectId = treeWalk.getObjectId(0);
            final ObjectLoader loader = repository.open(objectId);
            loader.copyTo(os);
        }
    }
 
    