C# GIT - 不能忽略 .suo 文件

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

GIT - Can't ignore .suo file

c#git

提问by Laxedur

I'm trying to work using Git - Extension with a colleague, in an application written in C#.

我正在尝试在一个用 C# 编写的应用程序中与同事一起使用 Git - Extension。

We have been added on the file .gitignore the file "project1.suo" but every time one of us have to commit the project, Git seems tell us to commit the file "project1.suo".

我们已经在文件 .gitignore 上添加了文件“project1.suo”,但是每次我们必须提交项目时,Git 似乎都告诉我们提交文件“project1.suo”。

We have tried many method to add the file in .gitignore like that:

我们尝试了很多方法来像这样在 .gitignore 中添加文件:

*.suo
project1.suo
c:\project\project1.suo

We cannot fix this problem.

我们无法解决这个问题。

采纳答案by Ikke

git doesn't ignore files that have been added to the repository. If you want to get it ignored, you have to delete the file from the repository:

git 不会忽略已添加到存储库中的文件。如果要忽略它,则必须从存储库中删除该文件:

git rm --cached project1.suo
git commit -m "Delete suo file from repository"

This will delete the file from the repository, while it's still on your harddrive.

这将从存储库中删除该文件,而它仍在您的硬盘驱动器上。

回答by Tsvetelina Tsvetanska

I had the same problem. Ikke's solution helps, but do not forget to remove the *.suo entry from your .gitignore, if it is there. After the file is corrected, do

我有同样的问题。Ikke 的解决方案有帮助,但不要忘记从 .gitignore 中删除 *.suo 条目(如果它在那里)。文件更正后,执行

git add **/*.suo

回答by Tareq

I always back to this question to use the method in the answer but i found a better solution which is to ignore the changes to this file . The method is

我总是回到这个问题以在答案中使用该方法,但我找到了一个更好的解决方案,即忽略对此文件的更改。方法是

git update-index --assume-unchanged project1.suo

or

或者

git update-index --assume-unchanged .vs/config/applicationhost.config

To undo this use --no-assume-unchanged

要撤消此操作,请使用 --no-assume-unchanged