[bug] ! prefix in .gitignore and .cursorignore is not honored (0.49.4)

In the documentation, it is said:

Cursor will also ignore all files listed in the .gitignore file in your root directory and in the > Default Ignore List provided below.
To not ignore a file listed in these files, add it to your .cursorignore file with an ! prefix.

Problem: It doesn’t work. If a file is ignored in .gitignore, it won’t appear in the Workspace explorer (and likely not in the codebase index as well) even if you explicitly asked to include it in .cursorignore. Cursor doesn’t honor the ! prefix in neither .gitignore or .cursorignore.

Configuration:

Version: 0.49.4
VSCode Version: 1.96.2
Commit: ec408037b24566b11e6132c58bbe6ad27046eb90
Date: 2025-04-22T00:17:03.731Z
Electron: 34.3.4
Chromium: 132.0.6834.210
Node.js: 20.18.3
V8: 13.2.152.41-electron.0
OS: Linux x64 6.8.0-58-generic

Test 1:
.gitignore:

* # (ignore everything)

.cursorignore :

# empty
  • Expected: workspace explorer should be empty.
  • Result: workspace explorer is empty :white_check_mark: (expected)

Double checking :white_check_mark:

$ git check-ignore -v api
.gitignore:1:*  api

Test 2:
.gitignore:

* # (ignore everything)
!api # except the api folder

.cursorignore :

# empty
  • Expected: workspace explorer should show api folder.
  • Result: workspace explorer is still empty :cross_mark: (:collision:)

Note: Reloading Developer Window doesn’t help: it doesn’t show.

Double checking to confirm that the .gitignore rule works as intended:

$ git check-ignore -v api
.gitignore:2:!api       api

More information

  • Adding !api to .cursorignore has no effect:

  • Even a direct test (without the *) doesn’t work: the api folder doesn’t show in the explorer, proving that Cursor doesn’t honor the ! prefix in neither .gitignore or .cursorignore.

cc @ericzakariasson that I’ve seen being helpful on .cursorignore related reported issue :folded_hands:

2 Likes

I’m seeing trouble with the ! in .cursorignore and .cursorindexignore as well. Any folder i have prefixed with ! doesn’t seem to get indexed, instead it remains greyed out in the cursor sidebar.

my scenario, .gitignore:

DerivedData

my .cursorignore:

DerivedData
!DerivedData/EssentialMCP/SourcePackages/checkouts/

That checkouts subfolder is not being indexed, but i believe it should be indexed based on my reading of Cursor – Ignore Files

1 Like

Hello, I had the same problem, but it was because I wasn’t doing it correctly. This worked for me!

Explanation:
vendor/** → ignores everything under the vendor/ directory, recursively.
!vendor/github.com/ → unignores the github.com/ folder, which would otherwise still be ignored.
!vendor/github.com/yourpackage/ → unignores the yourpackage/ folder.
!vendor/github.com/yourpackage/** → unignores everything recursively within the yourpackage/ folder.

Check out my solution below. Hope it helps you in time :slight_smile:

Thanks! If i’m understanding right, the difference is that instead of:

DerivedData
!DerivedData/EssentialMCP/SourcePackages/checkouts/

I should be doing:

DerivedData/**
!DerivedData/EssentialMCP/SourcePackages/checkouts/**

Is that the root of the solution, to use the recursive /** syntax instead of only the folder names?


DerivedData/
!DerivedData/EssentialMCP/
!DerivedData/EssentialMCP/SourcePackages/
!DerivedData/EssentialMCP/SourcePackages/checkouts/
!DerivedData/EssentialMCP/SourcePackages/checkouts/**

Should works.

1 Like