- 81comments
- 21comments
- 126comments
- 7comments
- 48comments
- 56comments
- 787comments
- 52comments
- 1004comments
- —discuss
- 22comments
- 239comments
- 410comments
- 8comments
- 216comments
- 13comments
- 505comments
- 6comments
- 60comments
- 166comments
- 6comments
- —discuss
- 509comments
- 29comments
- 152comments
- 112comments
- 99comments
- 382comments
- 12comments
- 114comments
Ah, very good!
Thanks I had no idea about these either!
I'd never heard of .git/info/exclude, core.excludesFile, or ~/.config/git/ignore before. Thanks for posting this!
This is great, and nicely written up in the context of agentic repos etc, but presumably no-one reads the official docs, right: https://git-scm.com/docs/gitignore where the multiple ways of ignoring files are clearly stated?
There is a tweet doing numbers on Twitter right now which is effectively:
"Do the reading b/c you would be amazed how many people don't do the reading"
So many people treat git commands like magic words, and then are terrified when they mess up their repo (example in this xkcd... https://xkcd.com/1597/)
Reading documentation is a superpower
I'd wager a small sum that git is the tool most of us learned by accident, some of them fortunate, some less so. Thankfully, this one was the former.
I have never seen these two files in any git repository I've cloned so far.
That’s because, unlike .gitignore, they are not committed.
Until Claude suggested .git/info/exclude, it never crossed my mind to question how ignoring worked. A search would have answered it in seconds, but you have to think to ask first. I didn't, and I suspect most people don't either. Especially with git, which nearly everyone learns by doing; very few of us ever sit down and learn it properly. That's why I wrote it up: so a few more people can learn this the way we learn everything else in git, by accident.
Now that you mention it, I should add a link to those docs in the article. Thanks!
This is great... one thing I wish is to be able to exclude are lines, for instance some lines in my config that only benefits the work I do. Some configs don't allow extending and that's where this would come in handy. Anyone have any tricks for that?
You can from the checked in config file include a local file which is not checked in (only if it exists).
For example, with direnv, the `.envrc` in my projects usually has
And the repo also ships with a `.envrc.local.example` file.
You might be surprised, it's sort of possible. Ask your favourite AI agent about git clean filters, and .git/info/attributes, the per-clone sibling of .git/info/exclude. The docs are here: https://git-scm.com/docs/gitattributes#_filter