繁体   English   中英

JGit Java Git Library Unstaging Files

[英]JGit Java Git Library Unstaging Files

我无法重置在JGit中正常工作。 IE浏览器。 我可以将所有文件添加到索引中,我可以通过下面的命令从索引中删除/重置/取消其中一些文件,但它不适用于所有文件。 在JGit中取消暂存文件的正确方法是什么?

repository.getIndex().remove(getWorkignDirectoryAsFile(), new File(getWorkignDirectoryAsFile(), fileName));
repository.getIndex().write();

您可以使用JGit ResetCommand类从索引中删除文件:

ResetCommand reset = new Git(repository).reset();
reset.setRef(Constants.HEAD);
reset.addPath("foo.txt");
reset.call();

相当于一个普通的git reset命令

git.reset().setMode(ResetType.MIXED).call();

其中gitorg.eclipse.jgit.api.Git的实例,而ResetType是指org.eclipse.jgit.api.ResetCommand.ResetType

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM