不能忽略.suo 文件

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

我们已经将条目“ project1.suo”添加到。Gitignore 文件,但是每次我们必须提交项目时,Git 似乎都告诉我们也要提交文件“ project1.suo”。

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

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

我们无法解决这个问题。

53592 次浏览

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 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.

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

git add **/*.suo

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