@Test
    void verifyPushPull() throws Throwable {
        val props = casProperties.getServiceRegistry().getGit();
        props.setRepositoryUrl("https://github.com/mmoayyed/sample-data.git");
        props.setBranchesToClone("master");
        props.setStrictHostKeyChecking(false);
        props.setClearExistingIdentities(true);
        val cloneDir = FileUtils.getTempDirectoryPath() + File.separator + UUID.randomUUID();
        props.getCloneDirectory().setLocation(ResourceUtils.getRawResourceFrom(cloneDir));
        val repo = GitRepositoryBuilder.newInstance(props).build();
        assertTrue(repo.pull());
        assertFalse(repo.getObjectsInRepository().isEmpty());
        FileUtils.writeStringToFile(new File(cloneDir, "test.txt"), "test", Charset.defaultCharset());
        try (val git = Git.open(ResourceUtils.getRawResourceFrom(cloneDir).getFile())) {
            git.reset().setMode(ResetCommand.ResetType.HARD).setRef("HEAD~1").call();
        }
        repo.getCredentialsProvider().add(new CredentialsProvider() {
            @Override
            public boolean isInteractive() {
                return false;
            }

            @Override
            public boolean supports(final CredentialItem... items) {
                return true;
            }

            @Override
            public boolean get(final URIish uri, final CredentialItem... items) throws UnsupportedCredentialItem {
                return true;
            }
        });
        try {
            repo.commitAll("Test");
            props.setRebase(true);
            val repo2 = GitRepositoryBuilder.newInstance(props).build();
            repo2.pull();
            try (val git = Git.open(ResourceUtils.getRawResourceFrom(cloneDir).getFile())) {
                var log = git.log().setMaxCount(1).call();
                var revCommit = log.iterator().next();
                assertEquals("Test", revCommit.getFullMessage());
            }
            repo.push();
            fail("Pushing changes should fail");
        } catch (final Exception e) {
            LOGGER.error(e.getMessage(), e);
        }
    }
This is {@link GitRepositoryTests}.

@author Misagh Moayyed
@since 6.2.0
support/cas-server-support-git-core/src/test/java/org/apereo/cas/git/GitRepositoryTests.java