简体   繁体   English

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

[英]How to have git remove file from repository

I have a project that I have uploaded to github. 我有一个已上传到github的项目。 I have some files that are already added that I want removed. 我有一些已经删除的文件。 I just want them to exist locally in my folder. 我只希望它们在我的文件夹中本地存在。

My git ignore file is check in with the git repository. 我的git忽略文件正在使用git存储库签入。 I don't want ANY mention of these files any where in the repository. 我不想在存储库中的任何位置提及这些文件。 If I add them to git ignore file, there will be mention of them in the repository. 如果我将它们添加到git ignore文件中,则存储库中将提及它们。

Secondly what if I want my gitignore file to be ignored? 其次,如果我希望忽略我的gitignore文件怎么办?

How can I just make a file be COMPLETELY in a git initialized folder? 我怎样才能使文件完全在git初始化的文件夹中?

I have a project that I have uploaded to github. 我有一个已上传到github的项目。 I have some files that are already added that I want removed. 我有一些已经删除的文件。 I just want them to exist locally in my folder. 我只希望它们在我的文件夹中本地存在。

git rm --cached file1 file2...

will remove them from the repo but leave the files in your local directory. 将从存储库中删除它们,但将文件保留在本地目录中。 You can then add them to your .gitignore file so that git won't keep telling you that you have untracked files. 然后,您可以将它们添加到您的.gitignore文件中,以便git不会继续告诉您您有未跟踪的文件。

I don't want ANY mention of these files any where in the repository. 我不想在存储库中的任何位置提及这些文件。

There's not much you can do to remove them from existing commits that are already in the repository short of removing all the commits that include the files. 除了删除包含文件的所有提交之外,您没有什么能做的将它们从存储库中已有的提交中删除。 So if you want to pretend that these files never existed, you should probably just create a new repo with the current state of the project after you've removed the offending files. 因此,如果您要假装这些文件不存在,则应该在删除有问题的文件之后,仅使用项目的当前状态创建一个新的存储库。

Secondly what if I want my gitignore file to be ignored? 其次,如果我希望忽略我的gitignore文件怎么办?

put ".gitignore" inside .gitignore file 将“ .gitignore”放入.gitignore文件中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM