jgit发生,当使用Git.cloneRepository时Packfile被截断

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

[当我使用Eclipse jgit api Git.cloneRepository()克隆一个大型存储库时,会发生java.io.EOFException:Packfile被截断。在org.eclipse.jgit.transport.PackParser.fill(PackParser.java:1241)上。

我的代码:

CloneCommand cmd = Git.cloneRepository();
cmd.setDirectory(repo)
cmd.setGitDir()
cmd.setURI()
cmd.setCredentialsProvider()
cmd.setProgressMonitor()
cmd.setTimeout(600000)
git = cmd.call()

以下发生了trunck错误:接收对象:94%(143964/152511)

谢谢。

java eclipse jgit
1个回答
0
投票

最终,我使用ssh解决了这个问题。请注意,此仓库超出了4.5G![如果您的仓库足够大,例如大于4G,请不要使用HTTP格式URI与jgit进行克隆,您应该使用SSH URI与jgit api进行克隆,否则您将得到packfile被截断的错误。即使您使用最新的jgit版本

CloneCommand cmd = Git.cloneRepository()
cmd.setDirecotry()
cmd.setGitDir()
cmd.setURI()
cmd.setCredentialsProvider(new CredentialsProvider(){

})
cmd.setProgressMonitor(new TextProgressMonitor())
cmd.setTimeout(600000)
cmd.setTransportConfigCallback(new TransportConfigCallback(){
    @Override
    public void configure(Transport transport){
         SshTransport ssh = (SshTransport)transport
         ssh.setSshSessionFactory(new JshConfigSessionFactory(){
              @Override
              protected void configure(OpenSshConfig.Host host,Session 
              session){
                  session.setConfig("StrictHostKeyChecking","no"); 
              }
              @Override
              protected JSch getJSch(Final OpenSshConfig.Host hc,FS fs) 
              throws JSchException {
                  JSch jsch = super.getJSch(hc,fs);
                  jsch.removeAllIdentity();
                  jsch.addIdentity("/path/to/your/private key")//note must be 
//a rsa private key format,otherwise you will get the bad private key error 
                  return jsch;

              } 

         })
    } 
})
git = cmd.call();
© www.soinside.com 2019 - 2024. All rights reserved.