Globally ignore files in Git

1 minute read

I use RubyMine in my day-to-day work. This IDE generates the .idea directory, which contains mostly project settings and information about the workspace. Since other developers on the projects I work on use various IDEs, I don’t really want (and need) to share those config files with them.

Therefore, I constantly found myself adding the .idea directory to the .gitignore file. Fortunately, you can avoid this tedious process by globally ignoring files.

First, create your global gitignore file, e.g. ~/.gitignore_global and add your rules to it. Then, let the Git know it should use this file for all your repositories by calling

git config --global core.excludesfile ~/.gitignore_global

from the terminal.