Two Git ignore files nobody told me about
faithraven
88 points
63 comments
September 23, 2026
Related Discussions
Found 5 related stories in 70.6ms across 7,510 title embeddings via pgvector HNSW
- .gitignore Everything by Default der_gopher · 166 pts · September 05, 2026 · 59% similar
- The Git history command deserves more attention turbocon · 179 pts · July 14, 2026 · 50% similar
- git git git git git alexmolas · 41 pts · August 18, 2026 · 48% similar
- Lazygit amirmasoudabdol · 24 pts · September 05, 2026 · 47% similar
- What Comes After Git tangled · 13 pts · September 11, 2026 · 47% similar
Discussion Highlights (20 comments)
DamonHD
Ah, very good!
festive-minsky
Thanks I had no idea about these either!
biglyburrito
I'd never heard of .git/info/exclude , core.excludesFile , or ~/.config/git/ignore before. Thanks for posting this!
6LLvveMx2koXfwn
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?
psygn89
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?
dpkirchner
See also: git check-ignore You can use this subcommand to learn which ignore file is causing your files to be ignored. https://git-scm.com/docs/git-check-ignore
globular-toast
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.
ktm5j
Just a nit-pick, but some/repo/path/.gitignore isn't necessarily committed to the repo. For example, if your repo has no .gitignore file, you can totally add one in your clone without adding it to the tree. Of course then you can't do something like `git add .` without committing it. Also `~/.gitignore` works as a global gitignore. I usually stick something like `katie*` in there so I can copy some `script.sh` to `katie_script.sh` and then I can make changes that I don't want to commit. Quick edit: I'm not sure `~/.gitignore` works out of the box.. looks like I stuck that in my `~/.gitconfig` for excludesfile
cxr
I've never seen a .gitignore that was justified, ever. It probably shouldn't even exist. I've run into projects often enough with horked build scripts or bad docs about build pre-requisites, where upon failing partway through and necessitating some fix, the build failure leaves the tree in a state where it still won't build successfully even after fixing the thing that caused the original failure. The only fast fix is to rm .gitignore, then look at the output of git-status and rm -rf all the crap that it shows the original build attempt splattered everywhere before re-running the build script for a third attempt. Thanks, .gitignore. .gitignore is banished in every project I'm in charge of. Everyone is required to manage their personal .git/info/exclude themselves, and any changeset attempting to slip .gitignore into the project will get ipso facto rejected. (Anyone is free to submit a change that adds a file contrib/gitignore if you think you have a set of useful globs relevant to the project that will be a help to others, along with instructions to cp that file to .git/info/exclude, but .gitignore is not making it in.) Git needs to ship a git-ignore command (or extend git-config) that exclusively works by managing .git/info/exclude for you, including converting "legacy" .gitignore into the less anti-social version.
grimgrin
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`
henrydoughty
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
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]
havnagiggle
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.
n4bz0r
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.
tonymet
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.
BigTTYGothGF
> but pushing the silly filename I picked for my private notes to a remote repository feels unclean Pick a directory for them and ignore the directory. Other team members who want to keep their own notes can use that directory as well.
TrianguloY
I learned this while using IntelliJ, because it suggests both options. I searched for the difference and, once understood, I was able to use the knowledge everywhere. The other useful advice is when there is a full folder you want to ignore. Putting a .gitignore with a single "*" ignores the full folder...including the gitignore file itself. I do use it when I quickly need to ignore the .idea folder
teekert
Oh this is nice. I've fallen into the habit of ignoring /devtools and put any input for agents there,I mount it in the agent container and have it put it's auth and memory there, and plans. And a "start agent container"-script, because people have their own preferences when it comes to agents.
BerislavLopac
> editor clutter has no business in any project's .gitignore, and yet there it is, in most of them I couldn't agree more with this - except that, in practice, nobody bothers to add their own environment clutter to their own global (or even project-related) gitignore. So invariably we end up with PRs (and even main :scream:) peppered with various .vscode and similar lost souls.
BerislavLopac
I can't believe that this article is still alive and well on the interwebz: MacGyver vs James Bond - https://importantshock.wordpress.com/2008/08/07/git-vs-mercu...