从Jgit的远程分支中提取,并带有自身证书错误

问题描述 投票:1回答:2

我在正在使用的脚本中运行以下代码。

 Git git = Git.open(repoLocation);
 Repository repo = git.getRepository();
 git.checkout()
    .setName("feature/test")
    .setStartPoint("remotes/origin/feature/test")
    .call();
 git.pull()
    .setRebase(true)
    .call();

但是,我无法从名为“ test”的远程功能分支中提取。如何通过Jgit从该远程分支中拉出?

经过调试器后,我决定尝试在本地手动拉。键入

git pull

在我的bash终端中,出现以下错误:

fatal: unable to access 'https://[email protected]/path/to/repo.git/': SSL certificate problem: self signed certificate in certificate chain

我现在认为这是错误的根源。我该如何在本地将回购更改保持安全的同时进行操作(代码在分发给其他人的applet中运行-大多数在线回答都说禁用SSL验证,但我认为这不起作用)。

java git jgit
2个回答
0
投票

tech blog给出以下有关如何处理Jgit中分支的示例:

// Create a new branch
git.branchCreate().setName("newBranch").call();
// Checkout the new branch
git.checkout().setName("newBranch").call();
// List the existing branches
List<Ref> listRefsBranches = git.branchList().setListMode(ListMode.ALL).call();
for (Ref refBranch : listRefsBranches) {
System.out.println("Branch : " + refBranch.getName());
}
// Go back on "master" branch and remove the created one
git.checkout().setName("master");
git.branchDelete().setBranchNames("newBranch");

尝试执行git.fetch().setRemote("origin").call();,然后执行git.checkout().setName("newBranch").call();,然后再执行git pull,它应该可以工作。


0
投票

我的解决方案是在克隆存储库时使用RSA身份验证。它解决了我的问题。我按照this article的方法使用RSA身份验证,然后从那里调整了我需要的内容。

注意,我确实使用其他URL来克隆存储库。代替使用

https://[email protected]/path/to/repo.git/

我用过:

ssh://[email protected]/PATH/repo.git
© www.soinside.com 2019 - 2024. All rights reserved.