github/gitignore · Dotnet.gitignore
.NET .gitignore 템플릿 해설
Dotnet.gitignore가 bin·obj, Debug·Release, NuGet 패키지, MSBuild 바이너리 로그, 테스트 결과, .env를 무시하는 이유와 VisualStudio 템플릿과의 차이를 설명합니다.
Dotnet.gitignore는 .NET SDK 스타일 프로젝트(dotnet new로 만든 C#·F# 프로젝트)를 위한 간결한 템플릿이다. 템플릿 머리 주석이 밝히듯, Visual Studio를 쓴다면 IDE 관련 규칙이 훨씬 많은 VisualStudio 템플릿을 함께 쓰는 것이 좋다.
VS Code, Rider, 명령줄에서 개발한다면 이 템플릿만으로 빌드 결과와 도구 부산물을 대부분 막을 수 있다.
규칙별 해설
| 패턴 | 무엇을, 왜 무시하나 |
|---|---|
[Bb]in/[Oo]bj/[Dd]ebug/[Rr]elease/x64/x86/bld/ | 빌드 출력dotnet build가 만드는 어셈블리와 중간 파일(obj/project.assets.json 등)이다. 브래킷으로 Bin·bin 같은 대소문자 차이를 모두 잡는다. |
artifacts/project.lock.jsonproject.fragment.lock.json | .NET 산출물artifacts/는 .NET 8부터 쓸 수 있는 통합 출력 레이아웃 폴더이고, project.lock.json은 옛 project.json 시절의 복원 결과다. |
*.nupkg*.snupkg | NuGet 패키지dotnet pack으로 만든 패키지와 심볼 패키지다. NuGet 피드에 게시하는 산출물이다. |
*.binlog[Tt]est[Rr]esult*/[Bb]uild[Ll]og.*TestResult.xmlnunit-*.xmlCodeCoverage/ | 로그·테스트 결과MSBuild 바이너리 로그(-bl 옵션), 테스트·커버리지 결과다. 바이너리 로그에는 환경 변수 등 민감한 값이 담길 수 있어 공유에 주의한다. |
.env~$**~ | 환경·임시 파일환경 변수 파일, Office 문서를 열 때 생기는 잠금 파일(~$문서.docx), 에디터 백업 파일이다. |
실무에서 주의할 점
[Ll]og/규칙은 모든 깊이의log폴더를 무시한다. 소스 네임스페이스 폴더 이름이Log라면 예외 규칙을 추가한다.packages.lock.json(NuGet 잠금 파일)은 무시 대상이 아니다. 잠금 모드를 쓴다면 커밋한다.- 사용자 비밀은
dotnet user-secrets로 프로젝트 밖(사용자 프로필)에 저장하면 gitignore를 신경 쓸 필요가 없다.
원본 템플릿
Dotnet.gitignore
## A streamlined .gitignore for modern .NET projects## including temporary files, build results, and## files generated by popular .NET tools. If you are## developing with Visual Studio, the VS .gitignore## https://github.com/github/gitignore/blob/main/VisualStudio.gitignore## has more thorough IDE-specific entries.#### Get latest from https://github.com/github/gitignore/blob/main/Dotnet.gitignore# 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/# .NET Coreproject.lock.jsonproject.fragment.lock.jsonartifacts/# ASP.NET ScaffoldingScaffoldingReadMe.txt# NuGet Packages*.nupkg# NuGet Symbol Packages*.snupkg# dotenv environment variables file.env# Others~$**~CodeCoverage/# MSBuild Binary and Structured Log*.binlog# MSTest test Results[Tt]est[Rr]esult*/[Bb]uild[Ll]og.*# NUnit*.VisualState.xmlTestResult.xmlnunit-*.xml
템플릿 출처: github/gitignore/Dotnet.gitignore @356fd7b (2026-09-11) · CC0-1.0