I deleted python .pyc files from my local repo and what I thought I did was to delete from remote github.
I pushed all changes. The files are still on the repo but not on my local machine. How do I remove files from the github repo?
I tried the following:
git rm classes/file.pyc
git add .
git
and even:
git rm --cached classes/file.pyc
Then when I try and checkout the files I get this error.
enter code here`error: pathspec 'classes/redis_ha.pyc' did not match any file(s) known to git.
I now dont know what else to do. As of now I have a totally corrupted git repo.
Delete Files using git rm. The easiest way to delete a file in your Git repository is to execute the “git rm” command and to specify the file to be deleted. Note that by using the “git rm” command, the file will also be deleted from the filesystem.
Just in case anyone wants to delete all the files from the directory, use -r option for recursive. So the command will look like git rm -r /path-to-file-name/ then do the commit and push as mentioned in the above answer.
The git rm command can be used to remove individual files or a collection of files. The primary function of git rm is to remove tracked files from the Git index. Additionally, git rm can be used to remove files from both the staging index and the working directory.
You should not do git add
. That's all
git rm classes/file.pyc
git commit -m"bla bla bla"
git push
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