git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Expanding Includes in .gitignore

From
APAaron Pelly <aaron@pelly.co>
Date
Oct 27, 2016, 00:22 UTC
Message-ID
<80919456-7563-2c16-ba23-ce4fcc2777de@pelly.co>
I want a feature. It may be a bad-idea(tm). Advice appreciated.

I want git to be able to include, in its gitignore files, sub-files of ignores or have it understand a directory of ignore files. Or both.

The use case for this is where I did not write my own rules, but I want to keep them updated. https://github.com/github/gitignore is a damn good resource, but I want to pull it and include relevant bits project by project and/or system wide. I don't want to have to update many projects manually if that, or any other, repo changes.

A very brief look at dir.c would indicate that a recursive call from add_excludes to itself when it parses some sort of include tag would do it within a file. I'm sure it'd be pretty straight forward to hook into something in dir.c to parse directories too.

I'm thinking something like ". path/to/include/file" in an ignore file, and/or creating .gitignore.d and/or allowing $HOME/.config/git/ignore and $GIT_DIR/info/exclude to be directories. Or some sane and consistent mixture of these things.

In the case of a directory the plan would be to add links to files stored/sourced elsewhere. This does pose a precedence question which I haven't thought about yet, but probably makes it too hard for the limited value it brings.

There is also the issue of malicious/accidental recursion which I haven't thought about deeply either.

I would like to know the desirability/practicality/stupidity of such a feature as I believe it is within my skillset to implement it.

Next: Stefan Beller
Message 1 of 24 in “Expanding Includes in .gitignore”
  1. Aaron PellyOct 27, 2016
  2. Stefan BellerOct 27, 2016
  3. Aaron PellyOct 27, 2016
  4. Alexei LozovskyOct 27, 2016
  5. Aaron PellyOct 27, 2016
  6. Jeff KingOct 27, 2016
  7. Jacob KellerOct 27, 2016
  8. Aaron PellyOct 27, 2016
  9. Jeff KingOct 27, 2016
  10. Aaron PellyOct 27, 2016
  11. Jacob KellerOct 27, 2016
  12. Duy NguyenOct 30, 2016
  13. Aaron PellyOct 27, 2016
  14. Jeff KingOct 27, 2016
  15. Jeff KingOct 27, 2016
  16. Aaron PellyOct 27, 2016
  17. Aaron PellyOct 27, 2016
  18. Junio C HamanoOct 28, 2016
  19. Aaron PellyOct 28, 2016
  20. Duy NguyenOct 30, 2016
  21. Jeff KingOct 30, 2016
  22. Aaron PellyOct 27, 2016
  23. Aaron PellyOct 27, 2016
  24. Jeff KingOct 28, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.