相关疑难解决方法(0)

git二进制差异算法(增量存储)是否标准化?

Git使用增量压缩来存储彼此相似的对象.

此算法是否已标准化并在其他工具中使用?是否有描述格式的文档?它与xdelta/VCDIFF/RFC 3284兼容吗?

compression git binary-diff vcdiff

50
推荐指数
3
解决办法
2万
查看次数

使用JGit键可以安全地访问Git存储库

我正在使用JGit访问远程Git仓库,我需要使用SSH.JGit使用JSch提供安全访问.但是,我不确定如何为JGit设置密钥文件和已知的hosts文件.我试过的内容如下.

使用子类化JSchConfigSessionFactory创建SshSessionFactory的自定义配置:

public class CustomJschConfigSessionFactory extends JschConfigSessionFactory {
    @Override
    protected void configure(OpenSshConfig.Host host, Session session) {
        session.setConfig("StrictHostKeyChecking", "yes");
    }
}
Run Code Online (Sandbox Code Playgroud)

在我访问远程Git仓库的类中,执行以下操作:

CustomJschConfigSessionFactory jschConfigSessionFactory = new CustomJschConfigSessionFactory();

JSch jsch = new JSch();
try {
    jsch.addIdentity(".ssh/id_rsa");
    jsch.setKnownHosts(".ssh/known_hosts");
} catch (JSchException e) {
    e.printStackTrace();  
}
    SshSessionFactory.setInstance(jschConfigSessionFactory);
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚如何将此JSch对象与JGit关联,以便它可以成功连接到远程存储库.当我尝试使用JGit克隆它时,我得到以下异常:

org.eclipse.jgit.api.errors.TransportException: git@git.test.com:abc.org/test_repo.git: reject HostKey: git.test.com
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:137)
at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:178)
at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:125)
at GitTest.cloneRepo(GitTest.java:109)
at GitTest.main(GitTest.java:223)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) …
Run Code Online (Sandbox Code Playgroud)

java git ssh jsch jgit

13
推荐指数
3
解决办法
1万
查看次数

标签 统计

git ×2

binary-diff ×1

compression ×1

java ×1

jgit ×1

jsch ×1

ssh ×1

vcdiff ×1