【问题标题】:Git ignore file for VB.NET projectsVB.NET 项目的 Git 忽略文件
【发布时间】:2010-10-06 18:41:56
【问题描述】:

我想在 Windows 中将 VB.NET 项目置于 Git 控制之下(以前在 Visual Source Safe 之下 - 存储库损坏等长期悲伤的故事)。我应该如何设置忽略文件?我正在考虑使用的排除项是:

  • *.exe
  • *.pdb
  • *.manifest
  • *.xml
  • *.log(Git 在 Windows 上区分大小写吗?我也应该排除 *.log 吗?)
  • *.scc(我认为这些是 Visual Source Safe 遗留下来的 - 也许我应该删除它们?)

这是一个合理的列表吗?我应该排除目录吗?

【问题讨论】:

  • 我尝试了建议,但发现排除文件有点棘手。如果我用记事本编辑它,git 无法遵守排除的文件。我使用了来自 git-bash 的 vim,它工作正常。我还在目录排除项上加上了斜杠。不确定是否有必要。

标签: git vb.net gitignore ignore


【解决方案1】:

以下是我的 C# 项目:

ProjectName/bin
ProjectName/obj
*.user
*.suo
_ReSharper.*
*.sln.cache

删除 bin/obj 目录后,您无需排除 所有 EXE、XML 文件等 - 这很方便,因为这意味着您仍然可以放入所需的文件: ) (您可能有示例 XML 文件等)

【讨论】:

  • 很棒的列表,我遇到的一个问题是我没有为解决方案创建目录的一些项目,因此binobj 目录与.gitignore 位于同一目录中文件。我最终使用[Bb]in/[Oo]bj/ 来捕获两个位置以及大小写差异的规则。
【解决方案2】:

删除现有的 .scc 文件。它们是来源安全的垃圾。

您还需要排除:.licx(许可证文件)、.dll、.suo、.ncb、.vspcc、.vscc 和 .vssscc 文件。最后三个由 Visual Studio 生成,用于跟踪源代码控制绑定。

【讨论】:

  • 不要排除 DLL - 您需要包含您引用的任何库(NUnit 等)。
  • 显然,应逐个商店评估不包括 DLL 的内容。我们从源代码控制中排除 DLL,因为我们存储库中的所有 DLL 都是由编译器生成的。排除 \bin 可能会得到相同的结果。
【解决方案3】:

我们使用以下内容,我们所有的共享内容(dll、exe、bat 等)都保存在名为“lib”的文件夹中,这样它就保持干净,我们可以将任何我们想要的东西放在 lib 中,并且它被排除在外从忽略规则。

[Bb]in/
[Oo]bj/
!/lib
*.user
*.suo
_ReSharper.*
*.sln.cache
*.xap
*.vspcc
*.vscc 
*.vssscc

顺便说一句,是的 .gitignore 即使在 Windows 中也区分大小写,所以是的,您需要包含多个案例。如果您正在使用 Silverlight 或 WPF 应用程序,Visual Studio 有时会创建一个 Bin 文件夹而不是 bin。这同样适用于 Obj。一些外部工具也可以做到这一点。据我所知,扩展名在所有情况下都是小写的,除非你当然修改它(如果你想从git add . 命令中删除单个文件,另一种技巧,顺便说一句)。

【讨论】:

    【解决方案4】:

    不要忘记包含[Pp]ublish/

    【讨论】:

      【解决方案5】:

      在这里维护: https://github.com/github/gitignore

      # Build and Object Folders
      bin/
      obj/
      
      #User Specific Files
      *.user
      *.suo
      
      ## Ignore Visual Studio temporary files, build results, and
      ## files generated by popular Visual Studio add-ons.
      
      # User-specific files
      *.suo
      *.user
      *.sln.docstates
      
      # Build results
      [Dd]ebug/
      [Rr]elease/
      x64/
      *_i.c
      *_p.c
      *.ilk
      *.meta
      *.obj
      *.pch
      *.pdb
      *.pgc
      *.pgd
      *.rsp
      *.sbr
      *.tlb
      *.tli
      *.tlh
      *.tmp
      *.vspscc
      *.vssscc
      .builds
      
      # Visual C++ cache files
      ipch/
      *.aps
      *.ncb
      *.opensdf
      *.sdf
      
      # Visual Studio profiler
      *.psess
      *.vsp
      
      # Guidance Automation Toolkit
      *.gpState
      
      # ReSharper is a .NET coding add-in
      _ReSharper*
      
      # 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
      
      # Others
      [Bb]in
      [Oo]bj
      sql
      TestResults
      [Tt]est[Rr]esult*
      *.Cache
      ClientBin
      [Ss]tyle[Cc]op.*
      ~$*
      *.dbmdl
      Generated_Code #added for RIA/Silverlight projects
      
      # 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
      

      【讨论】:

        【解决方案6】:

        发现这非常全面...

        https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

        截至 2018 年 3 月 27 日

        ## Ignore Visual Studio temporary files, build results, and
        ## files generated by popular Visual Studio add-ons.
        ##
        ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
        
        # 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/2017 cache/options directory
        .vs/
        # Uncomment if you have tasks that create the project's static files in wwwroot
        #wwwroot/
        
        # Visual Studio 2017 auto generated files
        Generated\ Files/
        
        # 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
        
        # Benchmark Results
        BenchmarkDotNet.Artifacts/
        
        # .NET Core
        project.lock.json
        project.fragment.lock.json
        artifacts/
        **/Properties/launchSettings.json
        
        # StyleCop
        StyleCopReport.xml
        
        # Files built by Visual Studio
        *_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
        *.VC.db
        *.VC.VC.opendb
        
        # Visual Studio profiler
        *.psess
        *.vsp
        *.vspx
        *.sap
        
        # Visual Studio Trace Files
        *.e2e
        
        # 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
        
        # AxoCover is a Code Coverage Tool
        .axoCover/*
        !.axoCover/settings.json
        
        # Visual Studio code coverage results
        *.coverage
        *.coveragexml
        
        # 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
        # Note: 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
        
        # Microsoft Azure Web App publish settings. Comment the next line if you want to
        # checkin your Azure Web App publish settings, but sensitive information contained
        # in these scripts will be unencrypted
        PublishScripts/
        
        # NuGet Packages
        *.nupkg
        # The packages folder can be ignored because of Package Restore
        **/[Pp]ackages/*
        # except build/, which is used as an MSBuild target.
        !**/[Pp]ackages/build/
        # Uncomment if necessary however generally it will be regenerated when needed
        #!**/[Pp]ackages/repositories.config
        # NuGet v3's project.json files produces more ignorable 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
        *.appx
        
        # 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
        *.jfm
        *.pfx
        *.publishsettings
        orleans.codegen.cs
        
        # Including strong name files can present a security risk 
        # (https://github.com/github/gitignore/pull/2483#issue-259490424)
        #*.snk
        
        # 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
        ServiceFabricBackup/
        
        # SQL Server files
        *.mdf
        *.ldf
        *.ndf
        
        # Business Intelligence projects
        *.rdl.data
        *.bim.layout
        *.bim_*.settings
        *.rptproj.rsuser
        
        # Microsoft Fakes
        FakesAssemblies/
        
        # GhostDoc plugin setting file
        *.GhostDoc.xml
        
        # Node.js Tools for Visual Studio
        .ntvs_analysis.dat
        node_modules/
        
        # Visual Studio 6 build log
        *.plg
        
        # Visual Studio 6 workspace options file
        *.opt
        
        # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
        *.vbw
        
        # 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
        
        # CodeRush
        .cr/
        
        # Python Tools for Visual Studio (PTVS)
        __pycache__/
        *.pyc
        
        # Cake - Uncomment if you are using it
        # tools/**
        # !tools/packages.config
        
        # Tabs Studio
        *.tss
        
        # Telerik's JustMock configuration file
        *.jmconfig
        
        # BizTalk build output
        *.btp.cs
        *.btm.cs
        *.odx.cs
        *.xsd.cs
        
        # OpenCover UI analysis results
        OpenCover/
        
        # Azure Stream Analytics local run output 
        ASALocalRun/
        
        # MSBuild Binary and Structured Log
        *.binlog
        
        # NVidia Nsight GPU debugger configuration file
        *.nvuser
        

        【讨论】:

          猜你喜欢
          • 2010-09-08
          • 1970-01-01
          • 2012-06-26
          • 2021-12-23
          • 1970-01-01
          • 2016-04-09
          • 2018-06-29
          • 2015-12-12
          相关资源
          最近更新 更多