git 从 IntelliJ IDEA 的版本控制中删除文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36163781/
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
Remove file from Version Control in IntelliJ IDEA
提问by Francesco Menzani
I'm using IntelliJ IDEA Community Edition 2016.1. I've put my project under Git, hosted it on GitHub.
我正在使用 IntelliJ IDEA 社区版 2016.1。我把我的项目放在 Git 下,托管在 GitHub 上。
When I first hit that Share Project on GitHubbutton, every single file was selected to be put under version control.
当我第一次点击那个Share Project on GitHub按钮时,每个文件都被选中置于版本控制之下。
Now I want to exclude the module IML file from version control. Obliviously, I want to keep it on my hard disk. Unfortunately, I cannot find a way to do this. How do I achieve this?
现在我想从版本控制中排除模块 IML 文件。显然,我想把它保存在我的硬盘上。不幸的是,我找不到办法做到这一点。我如何实现这一目标?
I tried to delete it from the web interface, but I'm getting some fatal errors while pulling/pushing.
我试图从 Web 界面中删除它,但是在拉/推时出现了一些致命错误。
回答by XYz Amos
There is a little trick.
有一个小技巧。
- Go to
File Menu-> Settings | Version Control | Confirmation
, then check theShow options before adding to version control
setting under theWhen files are created
section. Alternatively, you could checkDo not add
. It is mandatory that you do not checkAdd silently
. - Delete the file you don't want to be tracked by VCS.
- Press Ctrl + Zto undo the removal of the file.
If IDE shows a popup window which lets you choose whether or not to add the new file to VCS, click
No
. - Commit your local changes, and the files are removed from VCS.
- 转到
File Menu-> Settings | Version Control | Confirmation
,然后检查Show options before adding to version control
该When files are created
部分下的设置。或者,您可以检查Do not add
. 您必须不检查Add silently
。 - 删除您不想被 VCS 跟踪的文件。
- 按Ctrl + Z取消删除文件。如果 IDE 显示一个弹出窗口,让您选择是否将新文件添加到 VCS,请单击
No
。 - 提交您的本地更改,这些文件将从 VCS 中删除。
回答by CodeWizard
Once you commit the file it will begin to be tracked.
In order to remove the file from this point you have to remove them from the repository.
提交文件后,它将开始被跟踪。
为了从此时删除文件,您必须从存储库中删除它们。
What you need to do now is to delete the entire .idea
folder, commit the deletion, add the idea
extension to your .gitignore
file.
您现在需要做的是删除整个.idea
文件夹,提交删除,将idea
扩展名添加到您的.gitignore
文件中。
Explaining how to do from command line, can be done via IDEA as well.
解释如何从命令行完成,也可以通过 IDEA 完成。
# Remove the file from the repository
git rm --cached .idea/
# now update your gitignore file to ignore this folder
echo '.idea' >> .gitignore
# add the .gitignore file
git add .gitignore
git commit -m "Removed .idea files"
git push origin <branch>
回答by Gerd
for subversion:
对于颠覆:
- go to file properties context menu > copy path
open terminal use "svn rm --keep-local" to remove
svn rm --keep-local /aa/bb/cc/myfile.txt
- 转到文件属性上下文菜单 > 复制路径
打开终端使用“svn rm --keep-local”删除
svn rm --keep-local /aa/bb/cc/myfile.txt