This topic was very confusing to me, so I looked it up and found this link - which confused me more.
My understanding is that:
git rm
removes the file from both the working directory (aka worktree, disk) and the staging area (aka index).
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.