【问题标题】:JGit PullCommand ExceptionJGit PullCommand 异常
【发布时间】:2012-08-07 12:06:08
【问题描述】:

我们正在使用 git 来维护我们的源代码。像 git@xx.xx.xx.xx:XYZ.git 这样的 URL。我正在使用 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

【问题讨论】:

    标签: jgit


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

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

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

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

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

      【讨论】:

      • 嗨..我们已经添加了 ssh 参数,并且我们正在使用 tortoise git 从 git 服务器推送和获取。但在这里我尝试使用 Jgit 来执行推送和拉取操作。
      • 好的,那我不知道。搜索密码。因为日志看起来很清楚:您的密码有问题。你应该看看提到的文件:C:\Users\Murugan.SOLVER.ssh\id_rsa
      猜你喜欢
      • 2018-02-03
      • 2013-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-07
      • 2023-03-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多