1

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!

tnoel999888
  • 584
  • 3
  • 12
  • 29
  • 2
    Try `git rm -r --cached dist` – devd Aug 22 '18 at 11:32
  • 1
    In case the previous comment isn't clear, `rm` and `git rm` are different commands. – ChrisGPT was on strike Aug 22 '18 at 11:53
  • `rm` is the Unix command to delete a file, not related in any way to Git. It also works on macOS (because it is also based on Unix) but not on Windows unless you use Git for Windows (aka Git Bash). [`git rm`](https://git-scm.com/docs/git-rm) is the Git command to untrack (and also remove it from the file system unless `--cached` is provided in the command line). – axiac Aug 29 '18 at 12:57

1 Answers1

2

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

tobias
  • 934
  • 8
  • 17