0

I am trying to use JGit to add all files to the index (stage area).

By doing git.add().addFilepattern(".").call() I get to add modified and new ones. But not deleted ones.

How to add all deleted ones as well? I tried git.add().addFilepattern("-u") but it does not work.

Related question (about adding specific deleted files, not all deleted files):
How can I use JGit to add deleted files to the index?

  • If you only care about doing this in jgit, why did you include the tag [tag:git]? Why did you include the tag [tag:java] at all? (Note the text that pops up if you hover over the tags in your question.) – torek Nov 26 '20 at 19:30
  • sorry, I removed them now – Krakowski mudrac Nov 26 '20 at 23:34

1 Answers1

0

Have you tried using setUpdate(boolean) ?

// fair warning : not tested, I only read JGit's doc
git.add().setUpdate(true).call()
// or
git.add().setUpdate(true).addFilepattern(".").call()
LeGEC
  • 46,477
  • 5
  • 57
  • 104
  • 2
    actually i just managed to make it work. I played with it for a lot and figured out the following: `git.add().setUpdate(true).addFilepattern(".").call(); // stage modified and deleted` `git.add().addFilepattern(".").call(); // stage modified and new` So basically when you have both then you get _new_, _modified_ & _deleted_ – Krakowski mudrac Nov 26 '20 at 23:39