Gitignore 不会忽略 .vs 文件夹

2024-01-26

我们已经尝试了 .gitignore 中的各种显式和通配符条目,但是隐藏的项目.vs文件夹作为 Visual Studio 的一部分不断得到提交。

由于这些是开发人员的个人设置,因此它们显然总是不同的并显示在 git diff 中。

我该如何解决它以忽略顶层的所有内容.vs存储库中的文件夹?


按照以下步骤操作,问题将会得到解决。

步骤1:将以下内容添加到文件.gitignore中。

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/

# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

# NUNIT
*.VisualState.xml
TestResult.xml

# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c

# DNX
project.lock.json
artifacts/

*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc

# Chutzpah Test files
_Chutzpah*

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap

# TFS 2012 Local Workspace
$tf/

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding add-in
.JustCode

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*

# MightyMoose
*.mm.*
AutoTest.Net/

# Web workbench (sass)
.sass-cache/

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings 
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets

# Microsoft Azure Build Output
csx/
*.build.csdef

# Microsoft Azure Emulator
ecf/
rcf/

# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/

# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs

# Since there are multiple workflows, uncomment next line to ignore bower_components 
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
*.mdf
*.ldf

# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings

# Microsoft Fakes
FakesAssemblies/

# GhostDoc plugin setting file
*.GhostDoc.xml

# Node.js Tools for Visual Studio
.ntvs_analysis.dat

# Visual Studio 6 build log
*.plg

# Visual Studio 6 workspace options file
*.opt

# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions

# Paket dependency manager
.paket/paket.exe
paket-files/

# FAKE - F# Make
.fake/

# JetBrains Rider
.idea/
*.sln.iml

步骤2:确保以上操作生效

如果问题仍然存在,那是因为设置.gitignore只能忽略原来的文件未追踪。如果某些文件已经包含在版本控制系统中,则修改.gitignore是无效的。 要彻底解决这个问题,需要打开Git Bash在存储库根文件夹中运行以下命令。

$ git rm -r --cached .
$ git add .
$ git commit -m 'Update .gitignore'

Certainly, you can also use Package Manager Console of Visual Studio to do the things in Step 2. Use PM console Then the issue will be completely solved.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Gitignore 不会忽略 .vs 文件夹 的相关文章

随机推荐

  • 计算 constexpr 时抛出异常会发生什么?

    当计算常量表达式来初始化constexpr抛出异常是可能的 例如 下面是一个防止常量表达式的计算溢出的示例 include
  • bin2hex(random_bytes()) 根据输入有多少个字符?

    我使用以下代码为我的应用程序生成一个简单的 UID private function createUid bytes random bytes 128 uid bin2hex bytes return uid 通过这样做 结果是 creat
  • OpenCV Mat 元素类型及其大小

    我对 OpenCV Mat 元素类型感到困惑 这是来自文档 There is a limited fixed set of primitive data types the library can operate on That is ar
  • 获取 AWS S3 存储桶中对象的所有版本?

    我已在存储桶上启用对象版本控制 我想获取该存储桶内密钥的所有版本 但我找不到这样做的方法 如何使用 S3 API 来实现这一目标 所以 今天早上我遇到了这堵砖墙 事实证明 这件看似微不足道的事情做起来非常困难 您想要的 API 是获取桶对象
  • Elasticsearch 中不区分大小写的搜索

    我尝试在 elasticsearch yml 文件中创建一个条目来创建与要点中提到的相同的自定义分析器 https gist github com 1403902 https gist github com 1403902 但我收到以下错误
  • 使用 ReadAsAsync() 反序列化复杂的 Json 对象

    我想在我的 mvc 项目中使用 ReadAsAsync 和 net 4 0 结果为空 如果我在地址栏输入 uri chrome 中的结果为 标签名称已更改
  • 在 Apache 服务器上禁用 OPTIONS HTTP

    Request OPTIONS HTTP 1 1 Host webcat staci com Connection Keep alive Accept Encoding gzip deflate User Agent Mozilla 5 0
  • 是什么让 php 会话保持活动状态?

    会话是否仅在您每次访问页面时保持活动状态session start 或者其他页面也让它保持活力 示例 与30分钟暂停 1 用户通过 session start 访问页面 25 分钟后 他们访问另一个 session start 页面会话保持
  • JOOQ - 相当于用于填充历史字段的休眠拦截器?

    环境 Spring应用程序 使用JOOQ 3 7 从模式自动生成JOOQ映射代码 使用Postgres作为我的数据库 我已经将一些代码从 Hibernate 移植到 JOOQ Hibernate 代码会根据上下文提取一些隐藏的身份验证详细信
  • 单击自定义按钮时获取行数据

    我正在使用免费的 jqgrid 4 14 我需要在我的网格中有一个自定义图像 某种邮件图标 当单击该图像时 它应该打开一个具有表单的模式窗口 其中包含消息中单击行的数据表单字段 还有其他几个字段 如发件人邮件 ID 收件人邮件 ID 和主题
  • 如何在Arduino上将int转换为字符串?

    如何转换 int n 到一个字符串 以便当我通过串行发送它时 它作为字符串发送 这是我到目前为止所拥有的 int ledPin 13 int testerPin 8 int n 1 char buf 10 void setup pinMod
  • “int”的问题

    我是编程新手 所以我想编写一个代码 让我输入一个二维数组 或者在我的例子中是一个矩阵 并随后打印它 include
  • 使用抽象方法覆盖默认接口方法

    我觉得很奇怪 想知道它是否是经常使用的东西 什么时候才能有用呢 public interface InterA Object getInfo throws Exception1 public interface InterB public
  • 为什么我使用 Spring Boot / Spring Social 指南示例获得与 twitter 的空连接?

    我按照 spring io 网站上的说明进行操作 http spring io guides gs accessing twitter http spring io guides gs accessing twitter 而且我没有建立连接
  • 是否可以在.NET 4.0框架上使用TLS1.2发送HttpWebRequest

    我的应用程序连接到 Experian 服务器 Experian 将很快停止支持 TLS 1 0 和 TLS 1 1 所有使用 HTTPS 的连接都必须使用 TLS 版本 1 2 我想对这个问题做一些研究并查看发送HttpWebRequest
  • UnobservedTaskException 没有杀死进程

    我试图理解 NET 4 0 中的 UnobservedTaskException 问题 所以我编写了以下代码 TaskScheduler UnobservedTaskException sender eventArgs gt Console
  • 如何在 Android 中从 Java 端将 android:gravity 设置为 TextView

    我可以用android gravity bottom center horizontal 在文本视图上的 xml 中获得我想要的结果 但我需要以编程方式执行此操作 我的文本视图位于tablerow如果这很重要relativelayout 我
  • 没有看到“已打开”Firebase 通知统计信息

    我通过覆盖 FirebaseMessagingService 的 onHandle 意图来手动处理 Firebase 通知 并使用意图生成通知 有没有办法手动报告打开到 Firebase 的通知 因为我没有将打开的统计信息报告回 Fireb
  • 将列表的每个元素转换为元组

    将列表的每个元素转换为元组 如下所示 l abc xyz test 转换为元组列表 newl abc xyz test 实际上我有带有这样的键的字典 所以为了搜索目的我需要有这些 您可以使用列表理解 http docs python org
  • Gitignore 不会忽略 .vs 文件夹

    我们已经尝试了 gitignore 中的各种显式和通配符条目 但是隐藏的项目 vs文件夹作为 Visual Studio 的一部分不断得到提交 由于这些是开发人员的个人设置 因此它们显然总是不同的并显示在 git diff 中 我该如何解决