Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
.gitignore for C# projects
# The following command works for downloading when using Git for Windows:
# curl -LOf http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore
#
# 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/
[Bb]in/
[Oo]bj/
# build folder is nowadays used for build scripts and should not be ignored
#build/
# 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
*.scc
# 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
# Temp files when opening LibreOffice on ubuntu
.~lock.*
# svn
.svn
# CVS - Source Control
**/CVS/
# Remainings from resolving 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/
# OS generated files #
Icon?
# Mac desktop service store files
.DS_Store
# SASS Compiler cache
.sass-cache
# Visual Studio 2014 CTP
**/*.sln.ide
# Visual Studio temp something
.vs/
# dotnet stuff
project.lock.json
# VS 2015+
*.vc.vc.opendb
*.vc.db
# Rider
.idea/
# Visual Studio Code
.vscode/
# Output folder used by Webpack or other FE stuff
**/node_modules/*
**/wwwroot/*
# SpecFlow specific
*.feature.cs
*.feature.xlsx.*
*.Specs_*.html
# UWP Projects
AppPackages/
#####
# End of core ignore list, below put you custom 'per project' settings (patterns or path)
#####
@roninJosue
Copy link

roninJosue commented Mar 10, 2018

Hello very nice, its work super, thanks :)

@Mochoa92
Copy link

Mochoa92 commented May 24, 2018

Nice, Thanks a lot !

@dllmr
Copy link

dllmr commented Jul 6, 2018

This is really helpful - thank you!

@ThijsJung
Copy link

ThijsJung commented Aug 25, 2018

This helped me a lot, thanks for sharing!

@kevinnz2020
Copy link

kevinnz2020 commented Sep 7, 2018

Thanks a lot!

@mwck46
Copy link

mwck46 commented Sep 15, 2018

Cheers!

@joshuaguenther
Copy link

joshuaguenther commented Sep 19, 2018

Super helpful, thank you!

@Genebi
Copy link

Genebi commented Jan 12, 2019

How to unignore a specific file inside Debug folder?

@vishwasgupta
Copy link

vishwasgupta commented Feb 9, 2019

I have checked in all the files bin , suo etc on git. Now each time when I build the solution my dll got updated and git desktop suggest me to checked in those changes. I don't want to checked those (.dll and .pdb files). Can anyone help me here?

@Grauldon
Copy link

Grauldon commented Apr 20, 2019

@Genebi Use the ! (Not) operator.

!path/filename

@Grauldon
Copy link

Grauldon commented Apr 20, 2019

@kmorcinek The following commands also work for downloading when using Git for Windows:

curl -LOf http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore
curl -Of https://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore

@kmorcinek
Copy link
Author

kmorcinek commented Apr 21, 2019

@Grauldon thx, done. (added)

@kmorcinek
Copy link
Author

kmorcinek commented Apr 21, 2019

@vishwasgupta you need to delete them all and then make a commit that deletes them.

@kmorcinek
Copy link
Author

kmorcinek commented Apr 21, 2019

@Genebi you can also add one file explicit, like:
git add -f my/ignore/file.foo
https://stackoverflow.com/questions/8006393/force-add-despite-the-gitignore-file/8006450#8006450

@thamhphanaugensoftwaregroupcom

@teamzz111
Copy link

teamzz111 commented Aug 16, 2020

usefull! thanks

@cesar-programmer
Copy link

cesar-programmer commented Dec 22, 2020

Thanks this is so usefull

@LassazVegaz
Copy link

LassazVegaz commented Dec 24, 2020

Thanks

@nMouginot
Copy link

nMouginot commented Apr 20, 2021

Thanks a lot for the sharing ! GitHub should add your gitIgnore in ".gitignore template". They currently have nothing for C# projects ! :'(

@veronicapc92
Copy link

veronicapc92 commented Apr 24, 2021

thank you!!

@JK2Kgit
Copy link

JK2Kgit commented Nov 9, 2021

there is *.log duplcated in line 53 and 58

@kmorcinek
Copy link
Author

kmorcinek commented Feb 25, 2022

@JK2Kgit thx, fixed.

@stettdev
Copy link

stettdev commented Mar 15, 2022

Helpful. Thank you :)

@Victor23HD
Copy link

Victor23HD commented Apr 13, 2022

Thanks my friend.

@soroshsabz
Copy link

soroshsabz commented Jun 9, 2022

ITNOA

Hi, I add UWP Projects publish directory, please update gist from https://gist.github.com/soroshsabz/9eeca47ad6161ada32957d434c396e11

thanks

@rsbold
Copy link

rsbold commented Jun 27, 2022

Very useful, thanks!

@rafaelsperati
Copy link

rafaelsperati commented Jul 28, 2022

Thank You!

@kulibinRuslan
Copy link

kulibinRuslan commented Aug 17, 2022

Thank you!!!

@Genebi
Copy link

Genebi commented Aug 28, 2022

@Genebi Use the ! (Not) operator.

!path/filename

Thank you so much

@kmorcinek
Copy link
Author

kmorcinek commented Oct 9, 2022

@soroshsabz thx for your commit, I have merged it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment