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?
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.
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.
git rm --cached: The --cached option only removes files from the staging index and doesn't affect files in the working directory.
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.
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