.NET 用 .gitignore
.NET 用の除外ルール 30 件。そのままリポジトリにコピーして使えます。
Microsoft の開発者向けプラットフォーム
.NET 用 .gitignore の完全版
# LFGitignore によって生成 - https://lfgitignore.com
# 作成日:2026-10-31 22:57:02 UTC
# 技術:.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
# 環境変数
.env
# Microsoft Officeの一時ファイル
~$*
# Emacsのバックアップファイル
*~
CodeCoverage/
*.binlog
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*.VisualState.xml
TestResult.xml
nunit-*.xml
.NET のルールで除外されるもの
以下の各パターンと、.gitignore に含める理由を説明します。
ビルド結果
| パターン |
除外対象 |
[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 |
.NET Core |
project.fragment.lock.json |
ビルド結果 |
artifacts/ |
ビルド結果 |
ASP.NET スキャフォールディング
| パターン |
除外対象 |
ScaffoldingReadMe.txt |
ASP.NET スキャフォールディング |
NuGet パッケージ
| パターン |
除外対象 |
*.nupkg |
NuGet パッケージ |
NuGet シンボル パッケージ
| パターン |
除外対象 |
*.snupkg |
NuGet シンボル パッケージ |
.env |
環境変数 |
その他
| パターン |
除外対象 |
~$* |
Microsoft Officeの一時ファイル |
*~ |
Emacsのバックアップファイル |
CodeCoverage/ |
その他 |
MSBuild バイナリおよび構造化ログ
| パターン |
除外対象 |
*.binlog |
MSBuild バイナリおよび構造化ログ |
MSTest テスト結果
| パターン |
除外対象 |
[Tt]est[Rr]esult*/ |
MSTest テスト結果 |
[Bb]uild[Ll]og.* |
MSTest テスト結果 |
NUnit
| パターン |
除外対象 |
*.VisualState.xml |
NUnit |
TestResult.xml |
NUnit |
nunit-*.xml |
NUnit |
この .NET 用 .gitignore の使い方
- 上の .NET 用ルールをコピーするか、ファイルを直接ダウンロードしてください。
- Git リポジトリのルートに .gitignore という名前のファイルを作り、ルールを貼り付けます。
- 対象のファイルがすでに追跡されている場合は、git rm -r --cached . を実行して再度コミットしてください。Git の除外ルールは未追跡のファイルにのみ適用されます。
- チーム全員で同じルールを共有できるよう、.gitignore をコミットします。