JGit Java Git库卸载文件 [英] JGit Java Git Library Unstaging Files

查看:185
本文介绍了JGit Java Git库卸载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法重置在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();


I can't get reset to work properly in JGit. Ie. i can add all files to the index, and i can remove/reset/unstage some of them from the index via the command below but it doesn't work for all files. What is the proper way to unstage files in JGit?

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

Also

解决方案

You can remove a file from the index using JGit ResetCommand class:

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

这篇关于JGit Java Git库卸载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆