Skip to content

explorer.excludeGitIgnore fails to show unignored files and directories #156077

Description

@memeplex

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.69.2
  • OS Version: macOS Monterey

Both directories and files inside those directories that were unignored in .gitignore fails to be shown by explorer.

Steps to Reproduce:

cd /tmp
mkdir test-repo
cd test-repo
git init
mkdir d
touch d/a
touch b
git add d/a
git add b
git commit -m 'Initial commit'
echo '*' > .gitignore
echo '!d/' >> .gitignore
echo '!d/a' >> .gitignore
echo '!b' >> .gitignore
mkdir .vscode
echo '{"explorer.excludeGitIgnore": true}' > .vscode/settings.json
code .

Check that only 'b' is listed in the explorer.

Back in the console, check that no file is ignored by git:

git check-ignore d
git check-ignore d/a
git check-ignore b

Maybe related: #156076

Activity

  1. memeplex commented on Jul 24, 2022

    @memeplex
    Author

    The documentation of excludeGitIgnore says:

    Controls whether entries in .gitignore should be parsed and excluded...

    Perhaps the problem is that it tries to replicate git ignore rules and falls short of it, instead of querying git for the ignore status of files.

  2. lramos15 commented on Jul 25, 2022

    @lramos15
    Member

    Perhaps the problem is that it tries to replicate git ignore rules and falls short of it, instead of querying git for the ignore status of files.

    Yes we try to emulate it because we do not have access to the git executable in core. This has some good benefits too such as not needing git installed for this to work and working in web. I'm surprised b shows up here because we don't support exclude patterns

  3. memeplex commented on Jul 25, 2022

    @memeplex
    Author

    we don't support exclude patterns

    Sorry, I'm not quite following you here. What do you mean with exclude patterns? !-prefixed one? Those would be re-include, or un-exclude, or better un-ignore patterns. If you mean that you don't support them at all then, yes, it's indeed surprising that b shows up here. Perhaps there is some partial support in place?

  4. lramos15 commented on Jul 25, 2022

    @lramos15
    Member

    ? Those would be re-include, or un-exclude, or better un-ignore patterns.

    Yeah these. There's definitely many improvements to be made with this parser. I think many of the issues listed all stem from our parsing being slightly different than gits

  5. memeplex commented on Aug 18, 2022

    @memeplex
    Author

    we don't support exclude patterns

    Logan Ramos (@lramos15) I'm still surprised about this statement. I've also reported #156076 some days ago. Now, take as an example this .gitignore:

    *
    

    in a repo where file a.txt has been added. VSCode is oblivious to this fact, it acts as if a.txt were ignored despite it being in the repo. Now if I change .gitignore to:

    *
    !a.txt
    

    the behavior of VSCode changes to unignore a.txt. #156076 is about the first behavior (ignoring a.txt), which is wrong. But that explicitly unignoring a.txt works around the issue seems to imply that VSCode does support !-patterns, at least to some extent.

  6. memeplex commented on Aug 18, 2022

    @memeplex
    Author

    So perhaps the situation is far from tidy, where

    1. git
    2. file explorer
    3. search & quick open

    have all different ideas of what's ignored and what's not?

  7. lramos15 commented on Aug 19, 2022

    @lramos15
    Member

    the behavior of VSCode changes to unignore a.txt. #156076 is about the first behavior (ignoring a.txt), which is wrong. But that explicitly unignoring a.txt works around the issue seems to imply that VSCode does support !-patterns, at least to some extent.

    Yeah technically we do try to support the most basic cases but complex cases break down more.

    Git is completely separate but search excludes and files.exclude to hide items in the explorer should operate the same. Its explorer.excludeGitIgnore which does some more massaging of the globs to attempt to match gits behaviors.

    If you're interested here's the code pointer for our parsing

  8. memeplex commented on Aug 24, 2023

    @memeplex
    Author

    I bumped into this again and rereading our old conversation I realize I wasn't explicit enough about differences between file explorer and search/quick open regarding unignored directories and files inside them. Take for example:

    *
    !/.bashrc
    !/.config/
    !/.config/radian/
    !/.config/radian/profile
    

    Here both file explorer and search/quick open recognize .bashrc, but only search/quick open recognizes .config/radian/profile.

  9. mietzen commented on Jan 21, 2024

    @mietzen
  10. Phrogz commented on Sep 9, 2025

    @Phrogz
    Image

    Showing an excerpt from a real-world case where a simple exclude rule in a nested .gitignore file causes files to disappear from the Explorer, that are included by git (and understood by tree to be included). b.csv and c.csv are considered by git, but not shown in the Explorer.


    The above case breaks even without the nested .gitignore file. Putting this in the root .gitignore isn't honored, either:

    *.csv
    !/src/a/b/*.csv
    
  11. added 2 commits that reference this issue on Mar 11, 2026
    5b56791
    d131c2c
  12. added this to the 1.120.0 milestone on May 9, 2026
  13. added a commit that references this issue on May 9, 2026
    fc0b83a
  14. added
    insiders-releasedPatch has been released in VS Code Insiders
    and removed
    unreleasedPatch has not yet been released in VS Code Insiders
    on May 11, 2026
  15. bryanchen-d commented on May 12, 2026

    @bryanchen-d
    Collaborator

    I can still repro the issue, only 'b' shows up in the explorer, we should see d, d/a.

  16. dmitrivMS commented on May 12, 2026

    @dmitrivMS
    Collaborator

    Bryan Chen (@bryanchen-d) Thanks, yes, that's correct - the PR fixed part of this, but not all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable bugfile-explorerExplorer widget issues

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions