gitignore 不会忽略 .suo Visual Studio 文件

标签 git github

我想做一些简单的事情,忽略 .suo 文件以及 bin 和 obj 文件夹提交到 git repo。我已经创建了 .gitignore 文件,它适用于 bin 和 obj 文件夹,但它一直允许提交 .suo 文件。 gitignore的内容很简单:

/build/
*.suo
*.user
_ReSharper.*/
*.sdf
bin/
obj/
Debug/
Release/
*.opensdf
*.tlog
*.log
TestResult.xml
*.VisualState.xml
Version.cs
Version.h
Version.cpp

首先我认为问题是 .suo 文件已经在 repo 上,所以我使用了一组 git 命令将它从 repo 中删除:

git rm "file.suo"
git commit -m "suo removed"
git pull origin master
git push origin master

一切顺利,.suo 已在本地删除,从 repo 中删除,并在下一次提交时再次推送到 repo 。

图片上是提交的.suo文件。

enter image description here

有人遇到过这样的问题吗?如何解决这类问题?

最佳答案

这可能是 GIT - Can't ignore .suo file 的副本

老实说,您可以试试这个建议。您在这里缺少的是从 git 存储库中删除已添加的 *.suo 文件。

另一个答案有一组很好的运行命令:

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

关于gitignore 不会忽略 .suo Visual Studio 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28759841/

相关文章:

git - 当我尝试推送提交时,VS Code 说我的分支没有远程分支,该分支出现在 VS Code 上的分支列表中的原点上

.net - Windows 上的 .NET 应用程序的 GitHub?

Git: merge pull 请求时如何对多个提交进行一次提交?

github - Travis 无法授权构建请求

github - 如何向 Travis 添加新的 GitHub 组织?

在 Windows 7 上使用外部程序时,git diff tmp 文件在 Windows 上无效

git - 为什么 LFS git 的 git push 问密码 3 次?

git - 查找在提交之间发生更改的目录

github - 我可以在不丢失链接目标的情况下将 github 存储库名称从大写更改为小写吗?

git - git 重置后完全删除 git 对象