yotiky Tech Blog

とあるエンジニアの備忘録

.gitignore ファイル のテンプレートを取得する

.gitignore ファイル のテンプレートを取得する方法を3つ紹介します。 1つは .NET 専用ですが。

github

github Webページでリポジトリを作成する際にテンプレートから選択して追加することができます。こちらはリポジトリのルートのみになります。

テンプレート一覧のもととなっているのは、おそらくこちらだと思います。 おそらくと言ったのはテンプレートリポジトリの最新のファイルと、実際に作成されるファイルと若干差があるためです。

サブディレクトリにそれぞれ適した gitignore ファイルを使いたい場合も、テンプレートリポジトリに対象のものがあれば使えるものを引用すると良いでしょう。

github.com

gibo

gibo は導入するとコマンドで gitignore ファイルを生成してくれるようになります。 Windows の場合はリポジトリをクローンして、パスを通す必要があります。

gibo で扱うテンプレートですが、こちらも元となっているのは github のテンプレートリポジトリです。 Webページで生成されるものと違ってリポジトリを直接見てそうなので最新のテンプレートになりそうです。

導入方法などはググるか、以下のサイトを参考にしてみてください。

www.fast-system.jp

dotnet

.NET Core 限定ですが、.NET Core SDK をインストールすると dotnet コマンドで gitignore ファイルを作成することができます。作成できるのは1種類のみで、プロジェクトの形式に応じた~的なことはできません。 また、 .NET Core のバージョンによって内容にも差があるとのことです。

docs.microsoft.com

以下のサイトも参考になります。

wonwon-eater.com

github のテンプレートリポジトリとは幾分加減があるようです。

次のものは github にのみ定義されているものです。

# Build results
[Ww][Ii][Nn]32/
[Ll]ogs/

# NUnit
nunit-*.xml

# ASP.NET Scaffolding
ScaffoldingReadMe.txt

# Coverlet is a free, cross platform Code Coverage Tool
coverage*[.json, .xml, .info]

# NuGet Symbol Packages
*.snupkg

# Business Intelligence projects
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd

続いて、SDK で生成したもののみに定義されているものです。

# JustCode is a .NET coding add-in
.JustCode

# Business Intelligence projects
*- Backup*.rdl

##
## Visual studio for Mac
##
# globs
Makefile.in
*.userprefs
*.usertasks
config.make
config.status
aclocal.m4
install-sh
autom4te.cache/
*.tar.gz
tarballs/
test-results/

# Mac bundle stuff
*.dmg
*.app

# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# JetBrains Rider
.idea/
*.sln.iml

##
## Visual Studio Code
##
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json