考虑我的本地存储库包含多个文件,在 checkout 文件的特定提交时,存储库中的其他文件被删除。
我正在使用以下API(git
是git存储库的实例)
git.checkout().setName(commitId).call()
这是检查特定文件的特定提交的正确方法吗?
最佳答案
setName()
的 JavaDoc 说
When only checking out paths and not switching branches, use
setStartPoint(}
to specify from which branch or commit to check out files.
对于addPath()
,它指出:
If this option is set, neither the
setCreateBranch()
norsetName()
option is considered. In other words, these options are exclusive.
因此我认为你应该使用
git.checkout().addPath( ... ).setStartPoint( ... ).call();
关于eclipse - 如何使用 JGit 将文件重置为特定提交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36541809/