JGIT拉NoHeadException

Bgv*_*983 9 java eclipse git egit jgit

何时尝试执行以下方法(使用JGIT库)

 private void pullRepo() throws  IOException,GitAPIException, WrongRepositoryStateException, InvalidConfigurationException, DetachedHeadException, InvalidRemoteException, CanceledException, RefNotFoundException, NoHeadException{
            Git  git = new Git(localRepo);
            git.pull().call();
    }
Run Code Online (Sandbox Code Playgroud)

我得到以下运行时异常:

org.eclipse.jgit.api.errors.NoHeadException: Pull on repository without HEAD currently not supported
at org.eclipse.jgit.api.PullCommand.call(PullCommand.java:161)
Run Code Online (Sandbox Code Playgroud)

有人知道如何解决这个问题吗?我使用的localRepo与我用于cloneRepository方法的方法相同,完全正常.

谢谢,bgvv1983

Bgv*_*983 10

以为我发现了我的错误.在我的项目文件夹中处于错误的级别.

我在../project(在你的shell中工作)级别而不是../project/.git级别.