Skip to content

「$HOME/git/ignore」と 「$GIT_DIR/info/exclude」と「.gitignore」の使い分け

Published: at 10:48

Table of contents

Open Table of contents



Rails6.1にあげた事でrake routesが使用できなくなり、RubyMineのrailwaysプラグインrake routesが必要)が動かなくなった。

— Ikuma_t (@ikumatdkr) 2021年1月2日


暫定対応として、routes.rakeファイルを作って[rails]( routesをラップしてる(毎回やるのは面倒😅)

— Ikuma_t (@ikumatdkr) 2021年1月2日







  1. .gitignoreに追記:特定のリポジトリを利用するすべての人が対象外とすべきものをここに追記する。
  2. $GIT_DIR/info/excludeに追記:特定のリポジトリで対象外とすべきだけれど、他の人に共有すべきではないものをここに追記する。
  3. $HOME/git/ignoreに追記:自分が利用するすべてのリポジトリで対象外とすべきものをここに追記する。

例えば今FJORD BOOT CAMPRailsアプリケーションの課題を進めていますが、その場合の設定例は次の通りです。



# See for more about ignoring files.## If you find yourself ignoring temporary files generated by your text editor# or operating system, you probably want to add a global ignore instead:#   git config --global core.excludesfile '~/.gitignore_global'# Ignore bundler config./.bundle# Ignore the default SQLite database./db/*.sqlite3/db/*.sqlite3-journal/db/*.sqlite3-*# Ignore all logfiles and tempfiles./log/*/tmp/*!/log/.keep!/tmp/.keep# Ignore pidfiles, but keep the directory./tmp/pids/*!/tmp/pids/!/tmp/pids/.keep# Ignore uploaded files in development./storage/*!/storage/.keep/public/assets.byebug_history# Ignore master key for decrypting credentials and more./config/master.key/public/packs/public/packs-test/node_modules/yarn-error.logyarn-debug.log*.yarn-integrity/public/uploads/*.env



# git ls-files --others --exclude-from=.git/info/exclude# Lines that start with '#' are comments.# For a project mostly in C, the following would be a good set of# exclude patterns (uncomment them if you want to use them):# *.[oa]# *~/lib/tasks/routes.rake



# General.DS_Store.AppleDouble.LSOverride# Icon must end with two \rIcon# Thumbnails._*# Files that might appear in the root of a Directories potentially created on remote AFP share.AppleDB.AppleDesktopNetwork Trash FolderTemporary Items.apdisk# RubyMine.idea.ediotorconfig

参考:Git - gitignore Documentation

Which file to place a pattern in depends on how the pattern is meant to be used.

Patterns which should be version-controlled and distributed to other repositories via clone (i.e., files that all developers will want to ignore) should go into a .gitignore file.

Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user’s workflow) should go into the $GIT_DIR/info/exclude file.

Patterns which a user wants Git to ignore in all situations (e.g., backup or temporary files generated by the user’s editor of choice) generally go into a file specified by core.excludesFile in the user’s ~/.gitconfig. Its default value is $XDG_CONFIG_HOME/git/ignore. If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/ignore is used instead.