[英]JGit sparse checkout keeps adding files
In Java, I'm working with JGit for performing some actions with a remote repository.在 Java 中,我正在使用JGit使用远程存储库执行一些操作。 However when I sequentially do a sparse checkout between versions with:
但是,当我在版本之间按顺序进行稀疏结帐时:
checkout.
setCreateBranch(false).
setName(tag).
addPath("server/scripts/").
setStartPoint(tag);
It keeps the last checkout file and adds new one.它保留最后一个结帐文件并添加新文件。 It only happens when the name of the files inside the directory are not the same.
只有当目录中的文件名不同时才会发生这种情况。 How could I avoid that when using checkout command this way?
以这种方式使用 checkout 命令时如何避免这种情况?
I thought about deleting files inside folder that is being checkout ( scripts , in this case), however I don't know if it will bring conflict when the file being 'downloaded' has the same name.我想删除正在结帐的文件夹内的文件(在这种情况下是脚本),但是我不知道当“下载”的文件具有相同名称时是否会带来冲突。
First note that setCreateBranch()
is false by default, hence there is no need to explicitly call setCreateBranch( false )
.首先请注意
setCreateBranch()
默认为 false ,因此无需显式调用setCreateBranch( false )
。
Furthermore, you cannot mix addPath()
and setName()
The JavaDoc for addPath()
says:此外,您不能混合使用
addPath()
和setName()
addPath()
的 JavaDoc 说:
If this option is set, neither the setCreateBranch(boolean) nor setName(String) option is considered.
如果设置了此选项,则既不考虑 setCreateBranch(boolean) 也不考虑 setName(String) 选项。 In other words, these options are exclusive.
换句话说,这些选项是排他的。
However, I am not sure if the behavior that you see is correct.但是,我不确定您看到的行为是否正确。 In doubt check with command-line git to see if it shows the same results and file a bug report if JGit differs.
有疑问,请使用命令行 git 检查它是否显示相同的结果,如果 JGit 不同,则提交错误报告。
To work around the orphan files, you can use the StatusCommand
to manually delete all untracked files:要解决孤立文件,您可以使用
StatusCommand
手动删除所有未跟踪的文件:
Status status = git.status().call();
for( String fileName : status.getUntracked() ) {
// delete fileName
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.