我们往代码仓库中提交代码时,如果将所有文件都提交上去,会提交很多临时目录和文件(如:bin目录中生成的dll文件,log日志,obj目录中的临时编译文件),这些文件会严重干扰我们的代码管理,因此需要将这些文件排除在提交范围外,Git中通过.gitignore文件来配置这些规则。

.gitignore忽略规则

语法:

  • 以”#”号开头表示注释;
  • 以斜杠“/”开头表示目录;
  • 以星号“*”通配多个字符;
  • 以问号“?”通配单个字符
  • 以方括号“[]”包含单个字符的匹配列表;
  • 以叹号“!”表示不忽略(跟踪)匹配到的文件或目录;

此外,git 对于 .ignore 配置文件是按行从上到下进行规则匹配的,意味着如果前面的规则匹配的范围更大,则后面的规则将不会生效;

示例:

# 此为注释 – 将被 Git 忽略*.a       # 忽略所有 .a 结尾的文件
!lib.a    # 但 lib.a 除外
/TODO     # 仅仅忽略项目根目录下的 TODO 文件,不包括 subdir/TODO
build/    # 忽略 build/ 目录下的所有文件
doc/*.txt # 会忽略 doc/notes.txt 但不包括 doc/server/arch.txt

gitgnore项目

在github上面有一个开源项目,里面基本包括了所有常用的编程语言或IDE的.gitgnore配置,可以直接拿来使用,地址如下:

https://github.com/github/gitignore/

Visual Studio的.gitgnore模板

下面是Visual Studio的.gitgnore配置,ASP.NET和.NET Core都可以使用

## 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# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
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/# 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
*.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/
# ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true
**/wwwroot/lib/# 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# 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 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

ASP.NET和.NET Core项目.gitignore模板相关推荐

  1. 学习ASP.NET Core Razor 编程系列五——Asp.Net Core Razor新建模板页面

    学习ASP.NET Core Razor 编程系列目录 学习ASP.NET Core Razor 编程系列一 学习ASP.NET Core Razor 编程系列二--添加一个实体 学习ASP.NET ...

  2. 送福利 | 送书5本《ASP.NET Core项目开发实战入门》带你走进ASP.NET Core开发

    <ASP.NET Core项目开发实战入门>从基础到实际项目开发部署带你走进ASP.NET Core开发. ASP.NET Core项目开发实战入门是基于ASP.NET Core 3.1 ...

  3. 如何使用vs将asp.net core项目添加容器支持并发布docker镜像到私有dockerhub和添加k8s/helm管理...

    这篇文章介绍一下,如何使用VS2017给asp.net core添加容器支持,并发布镜像到私有docker hub,然后用chart管理容器镜像的操作流程. 话不多说,just do it. 新建项目 ...

  4. ASP.NET Core 项目简单实现身份验证及鉴权

    环境 VS 2017 ASP.NET Core 2.2 目标 以相对简单优雅的方式实现用户身份验证和鉴权,解决以下两个问题: 无状态的身份验证服务,使用请求头附加访问令牌,几乎适用于手机.网页.桌面应 ...

  5. 在传统.NET Framework 上运行ASP.NET Core项目

    新的项目我们想用ASP.NET Core来开发,但是苦于我们历史的遗产很多,比如<使用 JavaScriptService 在.NET Core 里实现DES加密算法>,我们要估计等到.N ...

  6. Asp.Net Core 项目实战之权限管理系统(0) 无中生有

    0 Asp.Net Core 项目实战之权限管理系统(0) 无中生有 1 Asp.Net Core 项目实战之权限管理系统(1) 使用AdminLTE搭建前端 2 Asp.Net Core 项目实战之 ...

  7. ASP.NET CORE系列【一】搭建ASP.NET CORE项目

    原文:ASP.NET CORE系列[一]搭建ASP.NET CORE项目 为什么要使用 ASP.NET Core? NET Core 刚发布的时候根据介绍就有点心里痒痒,微软的尿性都懂的,新东西bug ...

  8. 【无私分享:ASP.NET CORE 项目实战】目录索引

    简介 首先,我们的  [无私分享:从入门到精通ASP.NET MVC]   系列已经接近尾声,希望大家在这个过程中学到了一些思路和方法,而不仅仅是源码. 因为是第一次写博客,我感觉还是比较混乱的,其中 ...

  9. 各类最新Asp .Net Core 项目和示例源码

    1.网站地址:http://www.freeboygirl.com 2.网站Asp .Net Core 资料 http://www.freeboygirl.com/blog/tag/asp%20net ...

最新文章

  1. BYS推荐MS前端PhoneCall面试问题整理-1
  2. ubuntu_ftp_server配置方法
  3. wxWidgets:wxTrackable类用法
  4. Redis与RabbitMQ作为消息队列的比较
  5. 《直播疑难杂症排查》之二:播放卡顿
  6. SpringCloud 从菜鸟到大牛之三 服务拆分 理论
  7. Spark优化之小文件是否需要合并?
  8. Android反编译软件android killer教程
  9. 4309 消灭老鼠(哈希表存储一个向量表示一条直线)
  10. golang中的错误fatal error: concurrent map writes
  11. cocos2d-js 接入anysdk
  12. 计算机浮点数格式化表示方法,浮点数在计算机中是如何表示的
  13. java ping域名
  14. excel将常规数字转为日期格式
  15. c语言程序设计勘误,《程序设计基础教程(C语言)》勘误表
  16. 一文读懂CPU工作原理、程序是如何在单片机内执行的、指令格式之操作码地址码
  17. Beautiful english sentences,just for you.
  18. 【第十三届蓝桥杯省赛B组】统计子矩阵 (枚举前缀和+双指针)
  19. 全网最火的5款免费脑图软件,最后一款亮了!
  20. 利用busybox, extlinux 在工控机CompactFlash(CF卡)上构建Linux系统(下)

热门文章

  1. 盲盒商城系统的创业前景
  2. stm32步进电机控制教程
  3. R 数据分析方法(梅长林)exercise1-4
  4. python百度贴吧图片爬取
  5. 谁说必须多组学?非靶代谢基础研究思路及biomarker发现之路
  6. 海思平台入门1(基于海思Hi3559V200)
  7. matlab 雅可比矩阵求取
  8. rtk打点,导入arcgis并进行格式变换
  9. python安装setuptools
  10. 惠普(hp)3803tx xp 驱动程序 安装教程