JGit unstaging files/removing files from the index and ammending a commit
I figured out how to do a lot of things in the JGit library, such as commit files, find out the status of all files (ie. changed, modified, untracked etc), but i can't figure out how to unstage files i added to the index. Could someone let me know how to do this and maybe point me to some documenation as the eclipse site has none, and i can't find any on Google.
Also if anyone know how to ammend a开发者_JAVA百科 commit i would much appreciate knowing that too.
Thanks.
Looks like you found a way to unstage files but ran into trouble as explained in your other question:
repository.getIndex().remove(getWorkignDirectoryAsFile(), new File(getWorkignDirectoryAsFile(), fileName));
repository.getIndex().write();
Did you solve your issue with the above? I notice that repository.getIndex() is deprecated and org.eclipse.jgit.dircache.DirCache should be used instead.
To amend a previous commit, you should look at
org.eclipse.jgit.api.CommitCommand.setAmend(boolean)
Would be great if you could report on your own answers if you found any.
精彩评论