2

I have some buggy third-party script, which generates some files, I want to put into git. Now, the script does work mostly fine but at times fails and deletes files (I know this is horrible, ...).

Now, I would like to detect, when a file removal is added to the index and filter that out. The only solution that I could come up with would be to do git diff and search for deleted file mode and backstep to the path. This does seem pretty ugly, though.

Is there a better way of filtering this?

abergmeier
  • 13,224
  • 13
  • 64
  • 120

1 Answers1

1

Note that a simple git add only adds new or modified files, not deleted ones.
For that, you need a git add -u or git add -A.

That means you could consider doing only a git add after your script, and a commit.
Then a git checkout HEAD -- . would restore any deleted files.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks. I before did `git add mydirectory`, which also did stage the deletes. With `git add mydirectory/*.file` it works fine. – abergmeier Jun 22 '15 at 09:03