private Single<GitReference> getValidRef(GitService service, GitReference ref, String branch) {
        if (!isValidRef(ref)) {
            return service.getGitReference(repo.owner().login(), repo.name(), branch)
                    .map(response -> {
                        if (response.isSuccessful()) {
                            GitReference fetchedRef = response.body();
                            if (isValidRef(fetchedRef)) {
                                return fetchedRef;
                            } else {
                                throw new IOException("Reference does not have associated commit SHA-1");
                            }
                        } else {
                            throw new IOException("Request for Git Reference was unsuccessful");
                        }
                    });
        }

        return Single.just(ref);
    }
Create task to refresh repo's tree

@param repository
@param reference
app/src/main/java/com/github/pockethub/android/core/code/RefreshTreeTask.java