git 如何从 GitHub 存储库中删除文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11121352/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 13:58:24  来源:igfitidea点击:

How to remove files from the GitHub repository?

gitgithub

提问by Tampa

I deleted python .pyc files from my local repo and what I thought I did was to delete from remote github.

我从本地存储库中删除了 python .pyc 文件,我认为我所做的是从远程 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?

我推送了所有更改。这些文件仍在 repo 上,但不在我的本地机器上。如何从 github 存储库中删除文件?

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.

我现在不知道还能做什么。截至目前,我有一个完全损坏的 git repo。

回答by LiMar

You should not do git add. That's all

你不应该这样做git add。就这样

git rm classes/file.pyc
git commit -m"bla bla bla"
git push

回答by David Okwii

git commit -am "A file was deleted"
git push