private Git gitConstructForPush(final GitRepoDoc gitRepoDoc, final Path gitWorkDir)
            throws IOException, GitAPIException {

        this.ensureDirectoryExists(gitWorkDir);

        // Wipe everything from the local git Work dir
        this.deleteFileTree(gitWorkDir, false);

        // Clone the remote repo
        // Note depth is 1 - we only want the latest items not the history
        LOGGER.debug("Cloning repository '{}' to '{}' for push", gitRepoDoc.getUrl(), gitWorkDir);
        return Git.cloneRepository()
                .setURI(gitRepoDoc.getUrl())
                .setDirectory(gitWorkDir.toFile())
                .setCredentialsProvider(this.getGitCreds(gitRepoDoc))
                .setDepth(1)
                .setBranch(gitRepoDoc.getBranch())
                .setCloneAllBranches(false)
                .call();
    }
Creates a git object by cloning the remote repository.
Note that the returned object is auto-closeable (try with resources).

@param gitWorkDir The directory that is the root of the repo.
@return An auto-closeable Git object to use when accessing the repo.
@throws IOException if something goes wrong.
stroom-gitrepo/stroom-gitrepo-impl/src/main/java/stroom/gitrepo/impl/GitRepoStorageService.java