79642972

Date: 2025-05-28 20:41:03
Score: 1
Natty:
Report link

This topic was very confusing to me, so I looked it up and found this link - which confused me more.

My understanding is that:

  1. git rm removes the file from both the working directory (aka worktree, disk) and the staging area (aka index).

  2. git rm -cached removes the file from only the staging area

So if you created a whole new git repository, created a new file, added the new file to the staging area, then ran git rm -cached, basically all you've done is unstage the new file and the new file still exists in the working directory so it can be added back to the staging area. Had you ran git rm instead, you would have removed the file from the staging area AND the working directory so it couldn't be added back to the staging area without creating the file again.

I'm guessing the OP's original question was why PaginationResult.java was still listed in the staging area after running git rm --cached. At least that's where I'm still confused.

Reasons:
  • Blacklisted phrase (1): this link
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Chris Phillips