Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. Fixing the Portobello Police Station Clock(pointinthecloud.com)
    49comments
  2. UK military jamming other nations' satellites to defend itself, BBC told(bbc.com)
    1comments
  3. Radicle: Disclosure of Vulnerability in the Network Protocol(radicle.dev)
    18comments
  4. Gemini 3.8 text-to-speech(blog.google)
    64comments
  5. Jev in 25 Lines of Python(nobodywho.ai)
    158comments
  6. Italian parliament votes for return to nuclear energy(apnews.com)
    8comments
  7. Strands Harness(strandsagents.com)
    62comments
  8. 28% of job postings on company career sites have been open over 90 days(unlisted.careers)
    102comments
  9. GPT-6 Sol and Luna(openai.com)
    809comments
  10. Claude Code reads AGENTS.md only when telemetry is on [fixed](szypowi.cz)
    216comments
  11. Stripe's Knowledge AI Platform(stripe.dev)
    76comments
  12. Claude Opus 5.5(anthropic.com)
    1048comments
  13. Z80 REPL (2018)(abagames.github.io)
    14comments
  14. I don't want the details(michaelheap.com)
    136comments
  15. Web-based IBM 1620 emulator and IPL-V from 1963(github.com/pkimpel)
    5comments
  16. QuestDB (YC S20) Is Hiring a Sales Engineer(questdb.com)
    discuss
  17. Seattle City Council votes to ban surveillance pricing in sale of groceries(consumerreports.org)
    70comments
  18. GPT-6 Astra has gained the ability to drive a car(drivingbench.com)
    163comments
  19. OpenAI GPT–6 Astra breaks Enigma message that has resisted solution since 2005(cryptocellar.org)
    428comments
  20. Tokens Too Cheap to Meter(jyn.dev)
    117comments
  21. Transit rewards(waymo.com)
    283comments
  22. The GitHub wiki is an anti-pattern (2022)(michaelheap.com)
    76comments
  23. What California is learning from solar panels built over irrigation canals(kqed.org)
    636comments
  24. How did AMD Ryzen get 50% faster in two years?(lemire.me)
    181comments
  25. Microsoft killed FoxPro in 2007. Anyway, here's FoxPro revived(foxscript.org)
    238comments
  26. 'We hacked the FBI:' Hackers say they have data on all FBI employees(404media.co)
    553comments
  27. SAML: A fractal of bad design(trailofbits.com)
    167comments
  28. ReBarUEFI: Resizable BAR for almost any UEFI system(github.com/xcuri0)
    68comments
  29. What to do when your Waymo holds up a Secret Service motorcade(ft.com)
    1comments
  30. What to Know About JavaScript in 2026(master.dev)
    2comments

Two Git ignore files nobody told me about

73 pointsby 6h agomihai.dinculescu.dev
56 comments
6h agoHN ↗

Thanks I had no idea about these either!

4h agoHN ↗

I'd never heard of .git/info/exclude, core.excludesFile, or ~/.config/git/ignore before. Thanks for posting this!

4h agoHN ↗

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?

4h agoHN ↗

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"

4h agoHN ↗

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

4h agoHN ↗

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.

1h agoHN ↗

Yeah, but Git is a tool, that in the face of an accident shoves you it's manual in the face.

2h agoHN ↗

I'm definitely the friend in the alt-text of this comic. What do you mean you haven't read gitcore-tutorial(7)??

2h agoHN ↗

Do the reading b/c there's a machine that has done all the reading so it's hard to add value if you maintain the anti-intellectualism of 2010s software dev.

4h agoHN ↗

I have never seen these two files in any git repository I've cloned so far.

4h agoHN ↗

That’s because, unlike .gitignore, they are not committed.

4h agoHN ↗

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!

3h agoHN ↗

This is true, using AI to help discover better ways of working with stuff is pretty epic, reading docs are about as exciting as writing docs, esp when you are trying to get something done.

2h agoHN ↗

The motivation fades to make things intuitive.

2h agoHN ↗

For a lot of tools, people usually read the docs once, and obscure stuff is quickly forgotten.

4h agoHN ↗

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?

4h agoHN ↗

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

    source_env_if_exists .envrc.local

And the repo also ships with a `.envrc.local.example` file.

2h agoHN ↗

You missed this:

Some configs don't allow extending

3h agoHN ↗

That's a great shout. With more than one ignore file in play, this command is gold.

3h agoHN ↗

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.

3h agoHN ↗

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

3h agoHN ↗

True! But a gotcha there is that if your repo does have a .gitignore in the tree then this trick won't work. I had a coworker try to do just that and we were all pretty confused when his changes kept getting committed. `git add ./` will stage changes to any file in the commit tree, even if that file matches a line in gitignore.

3h agoHN ↗

In fact tup does exactly that to the .gitignores it generates.

3h agoHN ↗

Out of the box you can use ~/.config/git/ignore and ~/.config/git/config

3h agoHN ↗

I have no ~/.config/git directory, ~/.config/git/config might take higher precedence, but ~/.gitconfig works too.

3h agoHN ↗

Yes you may have to create the directory :)

3h agoHN ↗

I've been using $REPO/.scratch/ and .scratch/.gitignore with just `*` in it as a place for coding agents to use as temp storage (scripts, exports, plans, etc) that won't get committed. It's much easier to access these files under the repo path instead of wading through /tmp.

19m agoHN ↗

Wait until you learn about

  .git/exclude
  --assume-unchanged
  --no-update-index

.

And fwiw, I think global/home-dir .gitignore is bad, for everything except of OS-level spam like .DS-Store

3h agoHN ↗

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.

3h agoHN ↗

Or, you could have a build system that does a 100% out-of-tree build into ./build, and then if the build is broken you delete that one directory. You hardly need git to help you with that.

3h agoHN ↗

Oh, I can? Cool advice! How do I get the people with bad hygiene that we're talking about to follow it?

(You have lost the plot; your response amounts to explaining how soap and water works to someone who has just described their office mate's tendency not to shower.)

3h agoHN ↗

Get a new job? You can't be that "in charge of" a repo if you can't enforce rules this basic. In fact, I don't understand how you can enforce something as (being polite) unusual as banning .gitignore and yet can't enforce build system hygiene.

3h agoHN ↗

So all your fellow devs do `ln -s contrib/gitignore ./git/info/exclude`?

Also you can do `git status --ignored` and it will list all files changed, even if ignored. If that is really your main issue.

3h agoHN ↗

This is one of the strangest opinions I've seen in awhile. Your complaint seems like it should be pointed at projects not having a working "clean" make target.

Also:

  git status --ignored
  git clean -ndX # preview what would be removed
  git clean -fdX # actually delete the files (warning: destructive)
2h agoHN ↗

I would not recommend this setup, which is effectively using a more complicated and error prone system. That being said, I could handle it.

3h agoHN ↗

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`

3h agoHN ↗

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.

3h agoHN ↗

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]

2h agoHN ↗

The git-ness of this argument exceeds 100%.

2h agoHN ↗

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.

3h agoHN ↗

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.

3h agoHN ↗

What footguns? I disable most git hooks so your solution still has ways to shoot your feet.

2h agoHN ↗

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.

2h agoHN ↗

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.

2h agoHN ↗

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.

58s agoHN ↗

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.

2h agoHN ↗

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.

2h agoHN ↗

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.

1h agoHN ↗

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

1h agoHN ↗

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.