Eclipse Git 插件 - 从 repo 中删除文件而不删除本地
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8241509/
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
Eclipse Git plugin - remove file from repo without deleting local
提问by naomi
Using the Egit plugin, is it possible to permanently remove a file from source control without deleting the local copy?
使用 Egit 插件,是否可以在不删除本地副本的情况下从源代码管理中永久删除文件?
I.e., is there a GUI action equivalent to running "git rm --cached"?
即,是否有相当于运行“git rm --cached”的 GUI 操作?
(Edited to simplify question)
(编辑以简化问题)
采纳答案by naomi
I have found the answer. Team->Untrack is indeed the equivalent of "rm --cached". However there is a known bug which produces weird behaviour when you untrack and then try to commit.
我找到了答案。Team->Untrack 确实相当于“rm --cached”。但是,有一个已知的错误会在您取消跟踪然后尝试提交时产生奇怪的行为。
回答by Hermann Schwarz
Team -> Advanced -> Untrack
did the job (git rm --cached
) for me.
git rm --cached
为我做了()工作。
回答by dinafication
I had the same problem, after not initially including directories and files in .ignore. I also tried "Untrack" and "Remove from index" possibility, non of which helped(due to the still unresolved Egit issue). So, in the end I deleted files locally (leaving the project all in bugs), committed and pushed it to the github, and then undid the delete locally and added files to .ignore. Very unelegant, but it worked. I lost a lot of time and nerves on it, and I hope this helps someone.
我遇到了同样的问题,最初没有在 .ignore 中包含目录和文件。我还尝试了“取消跟踪”和“从索引中删除”的可能性,但没有帮助(由于仍未解决的 Egit 问题)。所以,最后我在本地删除了文件(将项目全部留在 bug 中),提交并将其推送到 github,然后在本地取消删除并将文件添加到 .ignore。非常不优雅,但它奏效了。我为此浪费了很多时间和精力,我希望这对某人有所帮助。
回答by VonC
Another option, similar to what Sri Sankaransuggests in the comments, is to update the index in order to assume no modification to your config file:
另一个选项,类似于Sri Sankaran在评论中建议的内容,是更新索引以假设不对您的配置文件进行修改:
On the preferences, in Egit, you can list "assumed unchanged" files :
在首选项中,在 Egit 中,您可以列出“假定未更改”的文件:
The file remains versioned and on the disk, but no modification will be detected on it.
该文件在磁盘上保持版本控制,但不会检测到任何修改。
回答by Orgatres
If you need to delete invisible folder(or file) from eclipse project:
如果您需要从 eclipse 项目中删除不可见的文件夹(或文件):
- Add folder(or file) to .gitignore file;
- Replace folder to another directory
- Team add to index, commit and push
- Replace folder(or file) to the project folder
- 将文件夹(或文件)添加到 .gitignore 文件;
- 将文件夹替换到另一个目录
- 团队添加到索引、提交和推送
- 将文件夹(或文件)替换为项目文件夹