java - 如何在裸存储库中使用 JGit 暂存文件?

标签 java git jgit

我读了question and answer for staging files in a non-bare repository .但是,我正在使用一个裸存储库,我想暂存文件。

我尝试使用 test for 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)

那么,我如何使用 JGit 在裸存储库中暂存文件?这甚至可能吗?

最佳答案

how could I stage files in a bare repository using JGit?

你不会,因为错误指出:

Bare Repository has neither a working tree, nor an index

没有索引,意味着没有暂存。

关于java - 如何在裸存储库中使用 JGit 暂存文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25549389/

相关文章:

java - @Autowire Spring Bean 带有注入(inject)的构造函数参数?

git - 将文件添加到 git 的阶段没有任何作用,也无法提交

java - 在 JGit 中包含 StrictHostKeyChecking 来克隆 git 存储库

jgit - 如何使用 JGit 记录两个发布标签之间的提交

java - Vaadin Bakery App 中的登录验证如何进行

java - 我怎样才能在java中得到总和?

java - 有一个带有文件夹路径的字符串,如何将其转换为文件以便能够使用 getDesktop.open() 打开它?

java - 提交后未显示更改 (Heroku Java)

windows - SourceTree 1.6.14 在 Windows 上找不到 Git 2.4.0 安装

java - 如何使用 JGIT 恢复到修订版