git android studio 从vcs中删除文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28333343/
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-19 10:44:47  来源:igfitidea点击:

android studio delete file from vcs

gitversion-controlandroid-studio

提问by Thomas Goureau

I'm looking for to exclude a file form versioning. I see the "add" to vcs button on a file but i doesn't find the "untrack" or "ignore" button like in eclipse.I tried to exclude folder .idea/. I tired to edit gitignore manualy and the ignore file button but nothing works. Any ideas ?

我正在寻找排除文件形式版本控制。我看到文件上的“添加”到 vcs 按钮,但我没有找到像 eclipse 中的“取消跟踪”或“忽略”按钮。我试图排除文件夹 .idea/。我厌倦了手动编辑 gitignore 和忽略文件按钮,但没有任何效果。有任何想法吗 ?

Thanks thomas

谢谢托马斯

回答by Artem M

You can remove tracked files from vcs manually using "Terminal" tab in Android Studio or Git Bash console.

您可以使用 Android Studio 或 Git Bash 控制台中的“终端”选项卡手动从 vcs 中删除跟踪的文件。

To untrack ignored files you should:

要取消跟踪被忽略的文件,您应该:

1) Make sure the files you want to ignore are properly listed in .gitignore

1) 确保您要忽略的文件在 .gitignore 中正确列出

2) Commit pending changes (important!)

2)提交挂起的更改(重要!)

3) Execute commands

3) 执行命令

git rm -r --cached . 
git add .

4) And then commit again:

4)然后再次提交:

git commit -am "Remove ignored files"

These steps will remove all the items from Git Index and then update it again, while respecting git ignores.

这些步骤将从 Git 索引中删除所有项目,然后再次更新它,同时尊重 git 忽略。

The reason for commiting pending changes at step 2 is that if the rm is part of another commit it doesn't work as expected.

在第 2 步提交挂起更改的原因是,如果 rm 是另一个提交的一部分,则它不会按预期工作。

Check more information in comments here.

此处的评论中查看更多信息。