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.

1 Like

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?

1 Like

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.

1 Like

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.

Wanted to check in, is this still an issue?

My use case: I manage a design system installed and used by teams at my company. It would be extremely helpful if Cursor could index and @ the files in the node modules directory.

Does not seem to have been updated in 0.50

Still cannot instruct Cursor to index a directory inside of node_modules.

I’m sure this is a huge use case.

Can anyone speak to the current status of this? Would be immensely helpful to have a bit of insight for planning. Thanks!

Just checking in. Pinging this thread to update it.

I’m really struggling with this too. Cursor tried to help me by telling me to just add negative entries to the .cursorignore but that didn’t work… and it later told me that it probably wouldn’t. I don’t understand the decisions here; I generate code because I need it to exist and it is key to the project’s execution but I don’t want to commit it. With the existence of a .cursorignore why even parse the .gitignore? If I’ve read the docs enough to create a .cursorignore surely I’m smart enough to copy what I want out of my .gitignore; I’m a programmer and maybe I even have a build step that grep -vE "gen|vendor" > .cursorignore and I’m golden.

Anyway- I want some way to pass some generated and vendored code as context but even removing these entries from my .gitignore in the hopes that Cursor would pick it up, it does only partially. I can @ the directories sometimes in the chat window but they don’t ever show up in the add context flyout.

Edit: After discovering the “Indexing & Docs” tab in Cursor Settings, having that open in a tab, letting “View included files” open in another tab, and then tabs for .gitignore and .cursorignore I think I’ve worked out how to make it go; maybe the arcane behavior is due to the way the .gitignore is specified to work but now my .cursorignore is longer than my .gitignore simply to include a few things that I want, which would be obviated by assuming that .gitignore meant “files that are important to the project but that don’t need to be in source control” instead of Cursor’s assumption of “files that are unimportant, why are they here if they have no meaning, are the devs dumb?”

For anyone else who stumbles by but doesn’t see the other threads, you’ve got to unignore the thing in your .gitignore and then unignore every parent directory on its own line up to the point where you can **/* it.

In my case, in a Go project where I don’t actually commit vendor dependencies but pull them down for reference, my .gitignore looks like

/vendor

and my .cursorignore looks like

!/vendor
/vendor/*
!/vendor/gitlab.com
/vendor/gitlab.com/*
!/vendor/gitlab.com/mycompany
/vendor/gitlab.com/mycompany/*
!/vendor/gitlab.com/mycompany/api_project
!/vendor/gitlab.com/mycompany/api_project/**/*
1 Like