Is it possible to index a file that's in my .gitignore?

I have a Typescript project. All node_modules are in my .gitignore

Some of the node_module dependencies have types I’d like to be able to have indexed and made available when interacting with the LLM.

Is it possible to add explicit overrides? Currently I have a workspace where the two root directories are my project and the dependency, but it’s a far from ideal workflow since some VSCode configs that I have in my project assume a base directory that is my project and not a parent directory.

You can add !path/to/folder to your .cursorignore to make sure the folder gets included even if it’s ignored by gitignore. Note that you may need to add !path/to/folder/* or !path/to/folder/**/* (see this SO answer for more details).

Thanks for the reply @arvid220u

I’m unable to verify whether this is working. I’ve opened a related topic since I’m unable to get Symbols to work for code in my node_modules

@arvid220u I tried doing this a different way and while I got Cursor to index the files in a dir that’s in my .gitignore, I’m unable to get the symbols to show up.

I created a ./tmp dir in my project that’s ignored by git and copied a dependency that’s in my ./node_modules into ./tmp. After I configured my .cursorignore to add negations for the ./tmp dir, resyncing the index resulted in the files in ./tmp being picked up.

I’m still unable to get anything that’s in tmp as an @ Symbol.

However, when I comment out the tmp dir in .gitignore, I’m able to use the @ Symbols! It looks as if Cursor has a blocklist for all files covered in .gitignore when it comes to @ Symbols, even if .cursorignore negates them and allows them to be indexed . Can you confirm this is the case? If so, can we update Cursor to respect the negated files in .cursorignore?

This is indeed the case! @ symbols currently do not follow the cursorignore file.

They probably should! Requires some careful work on our end, though, so may take some time.

1 Like

Got it, thanks for the response!

I’d love to see this improved. If it’s helpful to know, I’m generating a schema dump of the database to include as context in Chat. This let’s me get more relevant answers, but I’m having a hard time keeping it out of SCM. If I .gitignore the file or add it to .git/info/exclude it’s not available in Cursor Chat at all.

Is this feature add in yet? I want to get some files be index by cursor to use in LLM but don’t want add to git and got no way to make it works. Hope it soon

1 Like

Hi I’m facing the same problem too.
Use case: I want cursor to index a UI library and use it to to build the UI.
Because it’s source is in a git ignored folder it can’t do much with it, library is relatively new and updated daily.
I only got it to work by not .gitignoring the library’s folder.

Is there any expected support time? It’s a little urgent for me.

We’re actively working on improving how Cursor handles files in .gitignore, but there’s no specific timeline for this feature yet. For now, the workaround is to not .gitignore the files you need indexed - though I know that’s not ideal for your situation

I am working on a kotlin multiplatform project that generates a lot of files from openapi spec. I still need to reference them when working on ios and android clients, but i cant since we have them in .gitignore.
Please improve this. Thanks.