I wanted to clean my repo up after adding some files to .gitignore
so I ran
git rm --cached *
with the result:
fatal: pathspec '$Recycle.Bin' did not match any files
I assume this is due to the $
in the filename, is there a work around for this?
This is just how *
works. It has nothing to do with the $
at all.
$ ls
$Recycle.Bin
a
b
If I run git rm --cached *
, the shell converts that to git rm --cached $Recycle.bin a b
, and that's what's passed to Git.
However, $Recycle.Bin
isn't part of your repository, so Git can't delete it. That's an error. Easiest way to fix this is to not use --ignore-unmatch
.
$ git rm --cached --ignore-unmatch -- *
The workaround is to replace '*' with more bounded wildcard/globs. For instance you could use something of the form mydir/{dir1,dir2}/*.{js,css}
Which should give you some idea of what you can do.
Then look at your changes to .gitignore and do a git rm --cached on each line entry, using wildcards to combine entries in case your gitignore is bloated
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With