79385769

Date: 2025-01-24 22:17:40
Score: 2.5
Natty:
Report link

(Don't have the reputation to comment on the previous reply, but this is in reply to it)

Yes, there is! Using only git: git diff --name-only --diff-filter=A -z | git restore --staged -q --pathspec-file-nul --pathspec-from-file=-

This is really great, but git add -AN also stages file deletions, and this command doesn't unstage those file deletions. We can fully reverse the git add -AN command with this command:

cat <(git diff --name-only --diff-filter=A -z) <(git diff --staged --name-only --diff-filter=D -z) | git restore --staged -q --pathspec-file-nul --pathspec-from-file=-

We need to run two different commands and cat them, because we can only see the deleted files when using git diff --staged.

Reasons:
  • Blacklisted phrase (1): to comment
  • RegEx Blacklisted phrase (1.5): Don't have the reputation to comment
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: llakala