Running "git rm --cached" removes files from the .git folder?

2.9k Views Asked by At

I'm having trouble understanding what does git rm --cached do.

For example, I have a beagle_pft_test repo and a list of submodules inside "components folder". doing git rm --cached would delete it form the .git folder?:

enter image description here

Because when I type the following:

git rm --cached components/ChrgTmptrSen

And I get:

rm 'components/ChrgTmptrSen'

But I still see the component in the .git folder:

enter image description here

I'm not sure where did it remove it from? If I still see it in the .git folder, the .gitsubmodules file and the physical component in my local working directory

1

There are 1 best solutions below

2
VonC On

As I mentioned in "How do I remove a submodule?", you would need git submodule deinit -f -- a/submodule to unregister the given submodules, i.e. remove the whole submodule.$name section from .git/config folder. Plus a rm -rf .git/modules/a/submodule for cleanup.

The git rm --cached a/submodule is only needed if you still want the submodule files to still be visible on your disk, while the gitlink (special entry in the index) is removed from Git.