Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git unable to rm --cached files

Tags:

git

I want to remove all my *.pyc files from version control. I've tried git rm -r cached ./*.pyc but I got the error fatal: pathspec 'widgets.pyc' did not match any files. I thought widgets.pyc is not in version control but git status widgets.pyc says that my file is on branch master.

Any remedy for my problem?

like image 296
goh Avatar asked Sep 01 '11 10:09

goh


People also ask

How do I remove files from git cache?

To remove a specific file from the Git cache, use the git rm command followed by the specific file. To recursively remove files from the cache, use the -r flag with the git rm command. Replace the filename with the specific file you wish to remove from the Git cache.

Does git rm -- cached delete the file?

By default, the git rm command deletes files both from the Git repository as well as the filesystem. Using the --cached flag, the actual file on disk will not be deleted.

What is cached in git rm?

git rm --cached: The --cached option only removes files from the staging index and doesn't affect files in the working directory.


1 Answers

Try git rm -r --cached ./\*.pyc (note the backslash character before the asterisk) to ensure your command shell passes the wildcard character to git instead of expanding it itself.

like image 158
Barend Avatar answered Sep 22 '22 04:09

Barend