Top
Best
New

Posted by faithraven 1 day ago

Two Git ignore files nobody told me about(mihai.dinculescu.dev)
93 points | 63 commentspage 2
havnagiggle 1 day ago|
I prefer a presubmit check for DO NOT SUBMIT and also disable Git smart commits. And then I have those floating around as needed. Seems to avoid all the foot guns I'm reading about, and makes it obvious and easy for other people to use as well. I guess it still shows in my diff tree, but /shrug I still prefer seeing them.
etatester 1 day ago|
What footguns? I disable most git hooks so your solution still has ways to shoot your feet.
havnagiggle 1 day ago||
Mostly the spooky action at a distance. Gitignore expressions and inheritance of the ignore expressions can exclude files you actually need to include, and you basically lose sight of those -- admittedly those are probably safer bugs than including things that shouldn't be included. But if a file (or even specific lines) shouldn't be included, I would prefer the file/lines have a marker that says it shouldn't be included.

I run the same presubmits on pre-receive and merge requests, so you wouldn't get too far shooting your own foot. But yeah, if you're not using the feature then it wouldn't save you so it's not foolproof. I also run tools for scanning for credentials, etc.

henrydoughty 1 day ago||
On Windows I never found ~/.config/git/ignore. I just used .gitignore for everything.

I've been leaving notes sitting untracked rather than put a filename only I use into the repo. .git/info/exclude is what I actually needed.

markbnj 1 day ago||
Very useful. Minor typo in the post if you're adding the claude code flag: it's "respectGitIgnore" not "respectGitignore". [probably not true, see below]
faithraven 1 day ago|
Thanks, but I think it's the other way round. The docs, the published JSON schema and the binary itself all spell it respectGitignore, lowercase i, named after the .gitignore file. https://code.claude.com/docs/en/settings-reference#respectgi...
markbnj 1 day ago|||
When I first added it as "respectGitignore" it had no effect and my ignored folder did not show in the @ list. I changed it to "respectGitIgnore" and saved settings.json and the folder did show in the @ list. Then, after a claude restart, the folder stopped showing up. I edited and saved settings.json (but maintained the spelling "respectGitIgnore" and the folder started showing up again. Then after a coding session it stopped showing up, and changing the case of the 'i' and saving hasn't restored the behavior I want... so it just seems flaky at this point.
gritzko 1 day ago|||
The git-ness of this argument exceeds 100%.
biglyburrito 1 day ago||
I'd never heard of .git/info/exclude, core.excludesFile, or ~/.config/git/ignore before. Thanks for posting this!
grimgrin 1 day ago||
this was probably discovered by many when seeking how to globally ignore agent configs, until perhaps they decided they'd like to start committing agent configs. though that's just a `git add -f`
n4bz0r 1 day ago||
I absolutely despise when people commit their personal ignore patterns. My opinion is that the code in the repository shouldn't know anything about personal environments. The exception is when the entire team benefits from having their common ignore patterns in the repo - in this scenario, the environment details are no longer personal and it doesn't make much sense to not commit them. In any other situation, people are perfectly capable of ignoring their crap on their own and shouldn't pollute the repo. Glad .git/info/exclude is getting more exposure.
BeetleB 1 day ago||
> I absolutely despise when people commit their personal ignore patterns.

Beyond things not being neatly compartmentalized, what is the problem? The only risk I see is that you'll have a file you forgot to commit because it happened to match one of those patterns.

Having strong opinions on stuff like this is not healthy.

OutOfHere 1 day ago||
It depends on whether the pattern is general enough to potentially be useful for others. If it is, then by all means add it to .gitignore. If on the other hand it's specific to the user, e.g. '2026_report.docx', then no, it should not be added.
festive-minsky 1 day ago||
Thanks I had no idea about these either!
DamonHD 1 day ago||
Ah, very good!
tonymet 1 day ago||
Does anyone have a trick to blacklist files by type e.g. object / binary code, gz files. Often objects & commands lack extensions so going by extension doesn’t work. Git seems to guess binary pretty well upon diff, how to tap into that.

I’ve used pre-commit hooks for this but I’d rather a simple config flag, it seems trivial.

globular-toast 1 day ago|
Magit really is the only git frontend worth using. It exposes all of this kind of stuff in an easy to use way. You can easily ignore files using all three methods with magit.

The more useful thing here is the "typical use" of each one. People who don't know about other methods get this wrong a lot and put cruft from their own tools/editors in .gitignore which is annoying.

More comments...