3

For example, can you name a .gitignore file foo.gitignore?

Ultimately, the purpose for this being to have multiple .gitignore files for different sub-project types.

Kalcifer
  • 1,211
  • 12
  • 18
  • Does this answer your question? [Multiple .gitignore in subfolders](https://stackoverflow.com/questions/53208235/multiple-gitignore-in-subfolders) – Geeky Quentin May 14 '22 at 02:49
  • @GeekyQuentin not really. That's more for putting .gitignore files at multiple diffrent subdirectories. I was wondering if it was possible to have multiple gitignore files in the same directory, differentiating them through filenames. Although I do understand that it's probably better to just separate them into subdirectories. – Kalcifer May 14 '22 at 02:50
  • I'm not sure I fully understand your need. Would having a set of `.gitignore` file templates somewhere and copying the right one to each new repo fit your need ? – LeGEC May 14 '22 at 03:39

2 Answers2

3

Short answer: no, not natively.

I suggested before a content-filter driver which, on checkout, would automatically modify a .gitignore with the content of other files (like a foo.gitignore).

However, that require a local setting to activate that driver

git config filter.gitignore.smudge 'script_to_modify_gitignore'

Meaning: when you clone the repository, that mechanism would not be immediately active, not without the manual git config step.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

No, it can't. Well, more precisely, it can have a name, but that name is always .gitignore.

(Note that you can store entries in .git/info/exclude as well, but that is never a tracked file and does not get committed.)

torek
  • 448,244
  • 59
  • 642
  • 775