.gitignore for .NET

29 ignore rules for .NET, ready to copy into your repository.

Microsoft's developer platform

The complete .gitignore for .NET

# Generated by LFGitignore - https://lfgitignore.com
# Created: 2025-12-10 14:10:31 UTC
# Technologies: .NET

### .NET ###
[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/
project.lock.json
project.fragment.lock.json
artifacts/
ScaffoldingReadMe.txt
*.nupkg
*.snupkg
# Microsoft Office temp file
~$*
# Emacs backup files
*~
CodeCoverage/
*.binlog
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*.VisualState.xml
TestResult.xml
nunit-*.xml

What these .NET rules actually ignore

Every pattern below, and why it belongs in your .gitignore.

Build results

Pattern What it ignores
[Dd]ebug/ Build results
[Dd]ebugPublic/ Build results
[Rr]elease/ Build results
[Rr]eleases/ Build results
x64/ Build results
x86/ Build results
[Ww][Ii][Nn]32/ Build results
[Aa][Rr][Mm]/ Build results
[Aa][Rr][Mm]64/ Build results
bld/ Build results
[Bb]in/ Build results
[Oo]bj/ Build results
[Ll]og/ Build results
[Ll]ogs/ Build results
project.lock.json .NET Core
project.fragment.lock.json Build results
artifacts/ Build results

ASP.NET Scaffolding

Pattern What it ignores
ScaffoldingReadMe.txt ASP.NET Scaffolding

NuGet Packages

Pattern What it ignores
*.nupkg NuGet Packages

NuGet Symbol Packages

Pattern What it ignores
*.snupkg NuGet Symbol Packages

Others

Pattern What it ignores
~$* Microsoft Office temp file
*~ Emacs backup files
CodeCoverage/ Others

MSBuild Binary and Structured Log

Pattern What it ignores
*.binlog MSBuild Binary and Structured Log

MSTest test Results

Pattern What it ignores
[Tt]est[Rr]esult*/ MSTest test Results
[Bb]uild[Ll]og.* MSTest test Results

NUnit

Pattern What it ignores
*.VisualState.xml NUnit
TestResult.xml NUnit
nunit-*.xml NUnit

How to use this .gitignore for .NET

  1. Copy the .NET rules above, or download the file directly.
  2. Create a file named .gitignore at the root of your Git repository and paste the rules into it.
  3. If some of those files are already tracked, run git rm -r --cached . then commit again — Git only applies ignore rules to untracked files.
  4. Commit the .gitignore so everyone on the team shares the same rules.

Other Framework .gitignore templates

See every Framework template