Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

gitignore

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.

like image 293
Christoph Burschka Avatar asked Feb 03 '17 11:02

Christoph Burschka


2 Answers

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.

like image 124
Tom Avatar answered Nov 02 '22 22:11

Tom


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.

like image 2
hildensia Avatar answered Nov 02 '22 22:11

hildensia