Reputation: 1674
I read the question and answer for staging files in a non-bare repository. However, I am working with a bare repository and I would like to stage files.
I tried using the test for DirCacheBuilder, but the code Repository.lockDirCache()
or Repository.readDirCache()
fails because this is a bare repository.
org.eclipse.jgit.errors.NoWorkTreeException: Bare Repository has neither a working tree, nor an index at org.eclipse.jgit.lib.Repository.getIndexFile(Repository.java:993) at org.eclipse.jgit.dircache.DirCache.read(DirCache.java:166) at org.eclipse.jgit.lib.Repository.readDirCache(Repository.java:1017)
So, how could I stage files in a bare repository using JGit? is this even possible?
Upvotes: 3
Views: 978
Reputation: 2224
You can't "stage" files, but you can still add new file and commits to a bare repository. Here's a good snippet.
Upvotes: 1
Reputation: 1330102
how could I stage files in a bare repository using JGit?
You wouldn't, as the error states:
Bare Repository has neither a working tree, nor an index
No index, means no staging.
Upvotes: 6