windows .gitignore 不会忽略 visual studio 个临时文件

windows .gitignore is not ignoreing visual studio temporatry files

我不能忽略 windows git 中的目录。我下载了这个文件:- https://gist.github.com/kmorcinek/2710267。但我仍然一直看到:-

.vs/ 目录下的任何修改都不能报错。我确定我在正确的位置添加了 .gitignore 文件,如下所示:-

我的.git忽略文件:-

    # Download this file using PowerShell v3 under Windows with the following comand:
    # Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore
    # or wget:
    # wget --no-check-certificate http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore

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

    # Build results

                [Dd]ebug /
                [Rr]elease /
                x64 /
                build /
                [Bb]in/
                [Oo]bj /

    # 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

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

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

    # OS generated files #
    .DS_Store *
    Icon ?

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

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

    # Guidance Automation Toolkit
    *.gpState

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

    # TeamCity is a build add-in
    _TeamCity *

    # DotCover is a Code Coverage Tool
    *.dotCover

    # NCrunch
    *.ncrunch *
    .* crunch *.local.xml

    # 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
    *.Publish.xml

    # Windows Azure Build Output
    csx
    *.build.csdef

    # Windows Store app package directory
    AppPackages/

    # Others
    *.Cache
    ClientBin/
    [Ss]tyle[Cc]op.*
    ~$*
    *~
    *.dbmdl
    *.[Pp]ublish.xml
    *.pfx
    *.publishsettings
    modulesbin/
    tempbin/

    # EPiServer Site file (VPP)
    AppData/

    # 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

    # vim
    *.txt~
    *.swp
    *.swo

    # svn
    .svn

    # Remainings from resolvings conflicts in Source Control
    *.orig

    # SQL Server files
    * */ App_Data/*.mdf
    **/App_Data/*.ldf
    **/App_Data/*.sdf


    #LightSwitch generated files
    GeneratedArtifacts/
    _Pvt_Extensions/
    ModelManifest.xml

    # =========================
    # Windows detritus
    # =========================

    # Windows image file caches
    Thumbs.db
    ehthumbs.db

    # Folder config file
    Desktop.ini

    # Recycle Bin used on file shares
    $RECYCLE.BIN/

    # Mac desktop service store files
    .DS_Store

    # SASS Compiler cache
    .sass-cache

    # Visual Studio 2014 CTP
    **/*.sln.ide

    # Visual Studio temp something
    .vs /

    # VS 2015+
    *.vc.vc.opendb
    *.vc.db

    # Rider
    .idea /

    # Output folder used by Webpack or other FE stuff
    **/ node_modules/*
    **/wwwroot/*

    # SpecFlow specific
    *.feature.cs
    *.feature.xlsx.*
    *.Specs_*.html

    #####
    # End of core ignore list, below put you custom 'per project' settings (patterns or path)
    #####

我做错了什么?为什么我看到 .vs/ConsoleApp/v15/sqlite3/storage.ide 已修改?请告诉我如何忽略 windows 中的文件和目录?

经典的误解。

.gitignore 仅适用于未跟踪的文件,不适用于您已经提交(并且正在跟踪)的文件。

根据您的需要,有不同的解决方案:

  • 如果你是故意犯的,就继续犯。
  • 如果你不想提交它,因为它是一个错误,请停止跟踪它 git rm --cached .vs/ConsoleApp/v15/sqlite3/storage.ide
  • 如果您需要提交但不想提交更改,请使用 skip-worktree 功能:git update-index --skip-worktree <file>

.vs 文件夹中包含的大部分文件不应提交,因此,我认为您必须选择第二种可能性...