Allowing agent to read files in .gitignore

Hi,

I have files in .gitignore which I don’t want to commit but I want the agents to access, how do I do this?

Then a follow up question, why does agent care about git rules, they are completely different things. Cursor has its own rules already, why not just use those? Tons of users complaining this same problem online, surely I’m not the only one crazy?

Hey, good question.

To give the agent access to gitignored files, create a .cursorignore in your project root and override exclusions using negation patterns with !, like !my-folder/ or !notes.md. This overrides .gitignore rules for Cursor search and indexing, and it won’t affect git itself.

One caveat: if an entire parent folder is excluded, a negation for a nested file won’t work directly. You need to exclude more specifically, then reopen the exact file:

public/assets/*
!public/assets/style.css

Also important: the agent can always read a gitignored file directly if you @-mention it or provide the exact path. .gitignore only limits search and indexing, not direct reads.

On why the agent follows git rules at all: .gitignore usually marks build artifacts, dependencies, and secrets, so it’s a strong default signal to keep those out of search and the index. .cursorignore is Cursor’s separate rule layer, including the ability to override git rules.

More in the docs: Ignore File | Cursor Docs

Let me know if the negation still doesn’t work and we’ll dig in.