[英]How to stage files with JGit in a bare repository?
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. 我尝试使用DirCacheBuilder的测试 ,但代码Repository.lockDirCache()
或Repository.readDirCache()
失败,因为这是一个裸存储库。
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) org.eclipse.jgit.errors.NoWorkTreeException:Bare Repository在org.eclipse.jgit.dircache.DirCache上既没有工作树,也没有org.eclipse.jgit.lib.Repository.getIndexFile(Repository.java:993)的索引。 .read(DirCache.java:166)org.eclipse.jgit.lib.Repository.readDirCache(Repository.java:1017)
So, how could I stage files in a bare repository using JGit? 那么,我怎样才能使用JGit在裸存储库中暂存文件? is this even possible? 这有可能吗?
how could I stage files in a bare repository using JGit? 我怎么能使用JGit在裸存储库中暂存文件?
You wouldn't, as the error states: 你不会,因为错误说明:
Bare Repository has neither a working tree, nor an index
No index, means no staging. 没有索引,意味着没有分期。
You can't "stage" files, but you can still add new file and commits to a bare repository. 您不能“暂存”文件,但您仍然可以添加新文件并提交到裸存储库。 Here's a good snippet . 这是一个很好的片段 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.