Search code examples
gitcachinggithubrm

Git - rm: unrecognized option `--cached'


I added dist to my .gitignore but it was added to the tree in some other way.
I'm trying to remove it and clean up the tree using:

rm dist --cached

But am getting the error:

rm: unrecognized option `--cached'

Any help appreciated!


Solution

  • Running rm dist --cached will not work because the rm command does not have the --cached option.

    rm documentation: https://www.computerhope.com/unix/urm.htm

    The rm command is one of the basic Unix commands.


    The --cached flag is one of the options of the git rm command. Hence, you can run: git rm -r --cached dist to unstage and remove the dist folder from the index.

    git rm documentation: https://git-scm.com/docs/git-rm

    --cached Use this option to unstage and remove paths only from the index. Working tree files, whether modified or not, will be left alone.

    -r Allow recursive removal when a leading directory name is given.

    The following thread might give you more information as well: https://stackoverflow.com/a/1139797/5237070