JGit sparse checkout 不断添加文件
JGit sparse checkout keeps adding files
在 Java 中,我正在使用 JGit 对远程存储库执行一些操作。但是,当我按顺序在版本之间进行稀疏结帐时:
checkout.
setCreateBranch(false).
setName(tag).
addPath("server/scripts/").
setStartPoint(tag);
它保留最后一个签出文件并添加一个新文件。只有当目录中的文件名不相同时才会发生。以这种方式使用结帐命令时如何避免这种情况?
我考虑删除正在检出的文件夹中的文件(scripts,在这种情况下),但是我不知道当文件被 'downloaded'同名.
首先注意setCreateBranch()
默认为false,因此不需要显式调用setCreateBranch( false )
.
此外,您不能混合使用 addPath()
和 setName()
addPath()
的 JavaDoc 说:
If this option is set, neither the setCreateBranch(boolean) nor setName(String) option is considered. In other words, these options are exclusive.
但是,我不确定您看到的行为是否正确。如果有疑问,请检查命令行 git 以查看它是否显示相同的结果,如果 JGit 不同,请检查 file a bug report。
要解决孤立文件,您可以使用 StatusCommand
手动删除所有未跟踪的文件:
Status status = git.status().call();
for( String fileName : status.getUntracked() ) {
// delete fileName
}
在 Java 中,我正在使用 JGit 对远程存储库执行一些操作。但是,当我按顺序在版本之间进行稀疏结帐时:
checkout.
setCreateBranch(false).
setName(tag).
addPath("server/scripts/").
setStartPoint(tag);
它保留最后一个签出文件并添加一个新文件。只有当目录中的文件名不相同时才会发生。以这种方式使用结帐命令时如何避免这种情况?
我考虑删除正在检出的文件夹中的文件(scripts,在这种情况下),但是我不知道当文件被 'downloaded'同名.
首先注意setCreateBranch()
默认为false,因此不需要显式调用setCreateBranch( false )
.
此外,您不能混合使用 addPath()
和 setName()
addPath()
的 JavaDoc 说:
If this option is set, neither the setCreateBranch(boolean) nor setName(String) option is considered. In other words, these options are exclusive.
但是,我不确定您看到的行为是否正确。如果有疑问,请检查命令行 git 以查看它是否显示相同的结果,如果 JGit 不同,请检查 file a bug report。
要解决孤立文件,您可以使用 StatusCommand
手动删除所有未跟踪的文件:
Status status = git.status().call();
for( String fileName : status.getUntracked() ) {
// delete fileName
}