Christoph Burschka
Christoph Burschka

Reputation: 4689

Keeping multiple .gitignore files (local and remote) in the same repository

I have a repository with a .gitignore file, which excludes build paths (eg. vendor/ from Composer).

I also have some local IDE paths (eg. .idea from PhpStorm) that I want to ignore, but that aren't in the repository's .gitignore file.

I'm not sure how to do this. If git looked for files like .gitignore_* in the folder, then I could just add a .gitignore_local that contains (among other things) its own name.

Upvotes: 8

Views: 1996

Answers (2)

Tom
Tom

Reputation: 929

For local ignores, you can add them to the .git/info/exclude file. This is not shared to remote repositories.

So add to .gitignore all the files that should be ignored by anyone working with the repository. Add to .git/info/exclude files you use personnally but other people have no reason to have them, therefore to ignore them.

Upvotes: 16

hildensia
hildensia

Reputation: 1740

You can add a second .gitignore file with a single asterisk in the .idea directory. Thus all files in this directory are ignored and the directory itself is not shown as untracked file.

Upvotes: 3

Related Questions