JGit PullCommand Exception

时间:2012-08-10 07:42:50

标签: jgit

我们正在使用git来维护我们的源代码。像git@xx.xx.xx.xx这样的URL:XYZ.git。我正在使用JGit来进行更改。

UsernamePasswordCredentialsProvider user = new UsernamePasswordCredentialsProvider("xxxx", "xxxx");
localPath = "E:\\murugan\\Test\\GIT_LOCALDEPY";
Git git = new Git(localRepo);
PullCommand pcmd = git.pull();
pcmd.setCredentialsProvider(user);
pcmd.call();

执行代码时,我收到以下异常。

org.eclipse.jgit.errors.UnsupportedCredentialItem: ssh://git@xx.xx.xx.xx:22: 
org.eclipse.jgit.transport.CredentialItem$StringType:Passphrase for C:\Users\Murugan.SOLVER\.ssh\id_rsa

2 个答案:

答案 0 :(得分:0)

如果用户名/密码安全性不是问题,您可以在本地Git仓库的.git / config文件中将凭据指定为连接的一部分:

[remote "origin"]
    url = ssh://<user>:<pwd>@<host>:22/<remote-path-to-repo>/
    fetch = +refs/heads/*:refs/remotes/origin/*

答案 1 :(得分:-1)

在使用Git之前,您必须在计算机上配置SSH参数。这是来自github的链接,用于配置它。

https://help.github.com/categories/56/articles

尤其是这一个:https://help.github.com/articles/generating-ssh-keys

这将帮助您正确设置所有内容(您应该调整所有内容,因为您可能没有连接到GitHub)