code: public String getRemoteCommit(String branch) throws Exception {
          fetch();
          ObjectId commit = localRepo.resolve("origin/" + branch);
          if (commit != null)
              return commit.getName();
          else
              return null;
      }
docs: Get remote HEAD commit.