Authentification with JGit 's PullCommand
<p>I am using JGit and want to pull from the remote repository to my local repository.</p>

<p>The first approch was to clone the repository and that worked fine:</p>

<pre><code>CredentialsProvider cp = new UsernamePasswordCredentialsProvider(username, password);
try (Git result = Git.cloneRepository()
    .setURI("http://172.20.1.2/team/myrepo.git")
    .setDirectory(new File("c:\\temp\\gittest"))
    .setCredentialsProvider(cp)
    .call()) {
        System.out.println("Having repository: " + result.getRepository().getDirectory());
    }
</code></pre>

<p>But after the second call the repository does not need to be cloned again. Therefore I thought I need to pull</p>

<pre><code>Git git = Git.open(new File("c:\\temp\\gittest"));
git.pull().call();
</code></pre>

<p>But I get the following error:</p>

<pre class="lang-none prettyprint-override"><code>org.eclipse.jgit.api.errors.TransportException: http://172.20.1.2/team/myrepo.git: Authentication is required but no CredentialsProvider has been registered
</code></pre>

<p>I do not know where I can pass the pull command the credentials. </p>