Git has two more ignore files nobody told you about

Two Git ignore files nobody told me about

I used to let untracked files pile up because .gitignore gets committed and I didn't want to share my private notes. Then Claude Code asked if I wanted to add them to .git/info/exclude. It turns out Git reads ignore patterns from three places: the committed .gitignore, a per-clone .git/info/exclude, and a global file at ~/.config/git/ignore. The two uncommitted ones keep your scratch files and editor clutter out of the repo without exposing them.

The per-repo one, .git/info/exclude, is the one I'm giddy about. It lives inside .git, so it can't be committed even by accident, and nobody else ever sees it.
  1. 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

  2. 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?

  3. 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.

  4. 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

  5. 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.

More from this day

2026-09-23