Robo Robok
Robo Robok

Reputation: 22815

How to ignore directory globally in Git?

I want to completely ignore .idea folders in all my Git repositories. I want my repositories to not even know about files in this folder, so placing .gitignore file each time is not an option. I tried to globally set core.excludesfile in my global Git config, but it doesn't seem to work:

[core]
    excludesfile = .idea/**

Plus, it overwrites my system ignores, like .DS_STORE files. How can I ignore .idea folders entirely without letting know my repositories about these folders?

Upvotes: 3

Views: 2502

Answers (1)

torek
torek

Reputation: 489708

As described in the git config documentation, core.excludesFile is not a pattern, but rather the name of a file that contains patterns:

core.excludesFile

       Specifies the pathname to the file that contains patterns to describe paths that are not meant to be tracked, in addition to .gitignore (per-directory) and .git/info/exclude. Defaults to $XDG_CONFIG_HOME/git/ignore. If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/ignore is used instead. See gitignore(5).

Hence you should be putting .idea/** (or just .idea or .idea/*) in some file, and pointing core.excludesFile to that file if that is not already the default file.

Upvotes: 5

Related Questions