github/gitignore · Ruby.gitignore

Ruby .gitignore テンプレート解説

Ruby.gitignore が gem パッケージ、Bundler のインストールフォルダー、テスト結果、ドキュメント生成物を無視する理由と、Gemfile.lock・.ruby-version のコミット基準を説明します。

ジェネレーターで開く Rails, macOS, JetBrains と一緒に開く

Ruby.gitignore は gem を作ったり Ruby のスクリプト・アプリケーションを開発したりするプロジェクト向けである。ほとんどのルールが / で始まりリポジトリルートに固定されているため、同名のサブフォルダーを誤って無視することが少ない。

Rails アプリケーションなら、このテンプレートよりも Rails テンプレートの方が多くのケースを扱う。両方を選択すると、重なるルールは重複除去で整理される。

ルール別の解説

パターン何を、なぜ無視するか
*.gem/pkg/gem パッケージgem buildrake build が作るパッケージファイルである。RubyGems に公開する成果物である。
/.bundle//vendor/bundle/lib/bundler/man/Bundler.bundle/ にはローカルの Bundler 設定が、vendor/bundle には bundle install --path でインストールした gem が入る。別のコンピューターで再インストールできる。
/coverage//spec/reports//spec/examples.txt/test/tmp//test/version_tmp/テスト結果SimpleCov の結果、RSpec のレポート、RSpec が失敗したサンプルを記録する examples.txt などの実行結果である。
/.yardoc//_yardoc//doc//rdoc/ドキュメント生成物YARD・RDoc が作った API ドキュメントとキャッシュである。ソースのコメントから作り直せる。
/tmp/.byebug_history.repl_history*.rbc/.config/InstalledFiles一時・デバッガーファイル一時フォルダー、byebug・REPL の履歴、Rubinius のバイトコード、setup.rb のインストール記録である。
.rvmrcバージョンマネージャーの設定RVM の古いプロジェクト設定ファイルで、シェルコードを実行できるため共有を避ける。最近は主に .ruby-version を使う。

実務での注意点

元のテンプレート

Ruby.gitignoreルール 26 行
*.gem*.rbc/.config/coverage//InstalledFiles/pkg//spec/reports//spec/examples.txt/test/tmp//test/version_tmp//tmp/# Used by dotenv library to load environment variables.# .env# Ignore Byebug command history file..byebug_history## Specific to RubyMotion:.dat*.repl_historybuild/*.bridgesupportbuild-iPhoneOS/build-iPhoneSimulator/## Specific to RubyMotion (use of CocoaPods):## We recommend against adding the Pods directory to your .gitignore. However# you should judge for yourself, the pros and cons are mentioned at:# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control## vendor/Pods/## Documentation cache and generated files:/.yardoc//_yardoc//doc//rdoc/## Environment normalization:/.bundle//vendor/bundle/lib/bundler/man/# for a library or gem, you might want to ignore these files since the code is# intended to run in multiple environments; otherwise, check them in:# Gemfile.lock# .ruby-version# .ruby-gemset# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:.rvmrc# Used by RuboCop. Remote config files pulled in from inherit_from directive.# .rubocop-https?--*

テンプレートの出典: github/gitignore/Ruby.gitignore @356fd7b (2026-09-11) · CC0-1.0

一緒に使うテンプレート

ほかのテンプレートの解説