I am attempting to use JGit to create a local non-bare repository. I create the directory, then create a Repository
object for that directory, then I use repository.create()
. My research here shows that this is supposed to create a local non-bare repository. However, the line repository.create()
throws an exception
org.eclipse.jgit.errors.NoWorkTreeException: Bare Repository has neither a working tree, nor an index.
This would be the message that I would expect if I had created or referenced a bare repository, and then tried to add files to it. However, this error appears on the line that creates the repository, and I am very clearly making a non-bare repository. The documentation of the create method is: "Create a new Git repository. Repository with working tree is created using this method."
I have verified that the directory is created successfully.
What is going on here?
File repositoryPath = "test.git";
Repository repository = new FileRepository(repositoryPath);
repository.create(false); // This line throws the error