本文介绍了JGit克隆存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用JGit克隆Git存储库,而我对UnsupportedCredentialItem有问题。
I'm trying to clone Git repository with JGit and I have problem with UnsupportedCredentialItem.
我的代码:
FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository repository = builder.setGitDir(PATH).readEnvironment().findGitDir().build();
Git git = new Git(repository);
CloneCommand clone = git.cloneRepository();
clone.setBare(false);
clone.setCloneAllBranches(true);
clone.setDirectory(PATH).setURI(url);
UsernamePasswordCredentialsProvider user = new UsernamePasswordCredentialsProvider(login, password);
clone.setCredentialsProvider(user);
clone.call();
会发生例外:
org.eclipse.jgit.errors.UnsupportedCredentialItem: ssh://[email protected]:22: Passphrase for C:\Users\Marek\.ssh\id_rsa at
org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider.get(UsernamePasswordCredentialsProvider.java:110)....
但是,如果我删除.ssh中的文件known_hosts,则会发生不同的异常
But if I delete file known_hosts in .ssh\ It will occur different Exception
org.eclipse.jgit.errors.UnsupportedCredentialItem: ssh://[email protected]:22: The authenticity of host 'github.com' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting?
at org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider.get(UsernamePasswordCredentialsProvider.java:110)....
是否有可能在该问题上键入是或直接跳过?
Is there any possibility to type "yes" to that question or just skip it?
谢谢!
推荐答案
我认为,如果使用用户名和密码登录,则需要https。对于ssh,您将需要一个与github上记录的公钥匹配的公钥。
I think if you login with username and password, you need https. For ssh you will need a public key that matches the one on record with github.
这篇关于JGit克隆存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!