简体   繁体   English

jgit出现Packfile在使用Git.cloneRepository时被截断

[英]jgit occurs Packfile is truncated when use Git.cloneRepository

When I use eclipse jgit api Git.cloneRepository() clone a big repo ,it occurs java.io.EOFException:Packfile is truncated.当我使用 eclipse jgit api Git.cloneRepository() 克隆一个大仓库时,会发生 java.io.EOFException:Packfile is truncated。 at org.eclipse.jgit.transport.PackParser.fill(PackParser.java:1241) .在 org.eclipse.jgit.transport.PackParser.fill(PackParser.java:1241) 。

My code :我的代码:

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

it occurs trunck errors in below: Receiving objects: 94% (143964/152511)它发生以下中继错误:接收对象:94% (143964/152511)

Thanks.谢谢。

finally I resolve this question use ssh .notes this repo is beyond 4.5G !最后我使用 ssh 解决了这个问题。notes 这个 repo 超过了 4.5G! If your repo is big enough ,eg big than 4G ,don't clone with jgit using HTTP format URI, you ought to use SSH URI to clone with jgit api,otherwise you will got packfile is truncated error .even you use the lastest jgit version如果你的repo足够大,例如大于4G,不要用HTTP格式的URI用jgit克隆,你应该用SSH URI用jgit api克隆,否则你会得到packfile is truncated error。即使你使用最新的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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM