In brief
git rm --cached removes a selected file from the index while leaving its working copy on disk. A commit is needed to record that change in history.
Useful to know
git rm --cached removes a selected file from the index while leaving its working copy on disk. A commit is needed to record that change in history. [1]
It does not erase older versions of the file. If they contain a secret, untracking does not invalidate it. Add an appropriate ignore rule and separately address any data already exposed.
Sources
For further detail and to check the information: