gpt4 book ai didi

JGit PullCommand 异常

转载 作者:行者123 更新时间:2023-12-01 09:30:04 27 4
gpt4 key购买 nike

我们正在使用 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

最佳答案

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

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

关于JGit PullCommand 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11897404/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com