vs2019 git 提交忽略文件

本文指导如何在VS2019中设置Git忽略文件,避免提交临时、编译结果及第三方插件产生的文件。建议从GitHub的VisualStudio.gitignore获取最新模板,并列出了一系列可忽略的文件类型,包括Visual Studio的缓存、用户特定文件、编译结果、测试结果、代码覆盖率等。

点击工具-》源代码管理-》Git存储库设置-》常规-》Git files 忽略文件 编辑

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

*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates

User-specific files (MonoDevelop/Xamarin Studio)

*.userprefs

Mono auto generated files

mono_crash.*

Build results

[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/

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

ASP.NET Scaffolding

ScaffoldingReadMe.txt

StyleCop

StyleCopReport.xml

Files built by Visual Studio

*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.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

TeamCity is a build add-in

_TeamCity*

DotCover is a Code Coverage Tool

*.dotCover

AxoCover is a Code Coverage Tool

.axoCover/*
!.axoCover/settings.json

Coverlet is a free, cross platform Code Coverage Tool

coverage*.json
coverage*.xml
coverage*.info

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

NuGet Symbol Packages

*.snupkg

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

Nuget personal access tokens and Credentials

nuget.config

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
*.appxbundle
*.appxupload

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/
*.rptproj.bak

SQL Server files

*.mdf
*.ldf
*.ndf

Business Intelligence projects

*.rdl.data
*.bim.layout
.bim_.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl

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/

CodeRush personal settings

.cr/personal

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

MFractors (Xamarin productivity tool) working folder

.mfractor/

Local History for Visual Studio

.localhistory/

BeatPulse healthcheck temp database

healthchecksdb

Backup folder for Package Reference Convert tool in Visual Studio 2017

MigrationBackup/

Ionide (cross platform F# VS Code tools) working folder

.ionide/

Fody - auto-generated XML schema

FodyWeavers.xsd

VS Code files for those working on multiple tools

.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

Local History for Visual Studio Code

.history/

Windows Installer files from build outputs

*.cab
*.msi
*.msix
*.msm
*.msp

JetBrains Rider

.idea/
*.sln.iml

打开工具-》命令行-开发者命令行
输入如下命令 清除本地缓存(改变成未被追踪状态)然后再提交

git rm -r --cached .
git add .
git commit -m ‘update .gitignore’

### 回答1: 在Angular项目中,您可以使用.gitignore文件来指定要忽略文件文件夹,以便它们不会被提交Git存储库中。以下是一些常见的Angular项目中需要忽略文件文件夹: - node_modules/:这是所有依赖项的文件夹,通常很大,不需要提交Git- dist/:这是生成的构建文件夹,也不需要提交Git- *.log:日志文件通常会很大,不需要提交Git- /src/environments/environment.ts:这是包含环境变量的文件,通常与开发环境相关,不需要提交Git。 您可以在项目根目录下创建一个名为.gitignore的文件,并列出要忽略文件文件夹。例如,以下是一个典型的Angular项目的.gitignore文件: ``` # dependencies node_modules/ dist/ # logs and databases *.log *.sqlite # environment files /src/environments/environment.ts ``` 请注意,您可能需要根据您的项目情况进行调整。 ### 回答2: 在Angular项目中,我们可以通过.gitignore文件来指定哪些文件文件夹应该被Git忽略,从而不会被提交到版本库中。 首先,在Angular项目的根目录下创建一个名为.gitignore的文件,如果已经存在可以直接编辑该文件。 接下来,我们可以在.gitignore文件中添加需忽略文件文件夹列表。这些文件文件夹将不会被Git跟踪和提交。一般来说,可以忽略一些与构建、依赖和配置相关的文件。 下面是一个示例的.gitignore文件: ``` # 忽略dist文件夹 /dist/ # 忽略node_modules文件夹 /node_modules/ # 忽略一些构建和配置文件 /*.js.map /*.js /*.d.ts /.angular.json /package-lock.json ``` 在上述示例中,我们忽略了dist和node_modules文件夹,以及一些与构建和配置相关的文件。这样,当我们执行git提交命令时,这些被忽略文件将不会被包含在提交中。 需要注意的是,已经被Git跟踪的文件需要先从Git中移除才能被忽略。可以使用以下命令来移除已经被Git跟踪的文件: ``` git rm --cached <文件文件夹路径> ``` 在执行上述命令后,修改已保存的.gitignore文件,并重新提交。此时,被移除的文件将不再被Git跟踪,并且在之后的提交中也不会被包含。 通过使用.gitignore文件来指定需忽略文件文件夹,我们可以有效地管理项目中不需要被Git跟踪和提交文件,并确保版本库中只包含必要的文件。 ### 回答3: 在Angular项目中,我们可以使用.gitignore文件来告诉Git忽略某些文件文件夹的提交。下面是一些常见的在Angular项目中需要忽略文件文件夹。 1. 节点依赖:在Angular项目中,我们通常使用npm或者yarn来管理项目的依赖关系。这些依赖项通常存储在node_modules文件夹中,由于这个文件夹通常非常庞大且包含了大量的第三方代码,所以我们可以选择将其加入到.gitignore文件中。 2. 构建输出:当我们在Angular项目中运行构建命令时,会生成一些构建产物,例如编译后的JavaScript文件或者打包后的应用程序。这些文件通常存储在dist文件夹中,我们可以将其忽略以减少提交文件数量。 3. IDE生成的文件文件夹:不同的集成开发环境(IDE)可能会生成一些额外的文件文件夹,用于配置或者项目管理。例如,VSCode会生成一个.settings文件夹以保存项目的设置。我们可以根据自己使用的IDE,将这些文件文件夹加入到.gitignore文件中。 4. 日志文件:一些应用程序或插件可能会生成日志文件,用于调试或错误报告。由于这些日志文件通常会不断增长,并且可能包含敏感信息,所以我们可以选择将它们加入到.gitignore文件中。 可以在Angular项目的根目录下创建一个名为.gitignore的文件,并在其中列出需要忽略文件文件夹,可以使用通配符来进行模糊匹配。当我们进行git提交时,Git会自动忽略这些文件文件夹。需要注意的是,已经提交git仓库中的文件,即使在.gitignore中忽略,也不会被回退删除,需要手动删除或使用git命令进行操作。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值