Vscode: .gitignore'd files sometimes not greyed-out

Created on 22 Mar 2019  Â·  34Comments  Â·  Source: microsoft/vscode

Hi 👋

Sometimes files and folders that are in .gitignore and normally greyed-out just stop being greyed-out. #70099 may be related, see how in the first image in comment https://github.com/Microsoft/vscode/issues/70099#issuecomment-471596614 node_modules directory is not greyed out, however in the second one it is properly greyed-out again.

Here is a quick gif (I do ⌘⇧P — Reload window in the middle of it):

hello

Unfortunately, cannot reproduce 😞

  • VSCode Version: 1.32.3
  • OS Version: 10.14.3
bug git help wanted

Most helpful comment

I am facing same issue. But weird thing is if I edit .gitignore and save the file. It starts greying out correct files and folders!

All 34 comments

@jrieken I've been getting lots of these lately. I even saw it last week... Anything changed recently?

Anything changed recently?

Apart from the explorer no, the code hasn't changed since it was written.

Same here gitignore not graying folders and files

I've had a similar issue where it's graying things out that aren't ignored.

For example:

*.env
!*.env.example

Will gray out server.env.example despite Git tracking it as expected

I am having the same issue. I am using the TODO Tree extension, which depends on the .gitignore status. Some of my projects, where the node_module directory is grayed out properly, the extensions works fine, but other projects it doesn't the extension will pick up the prefix //TODO in the node-modules directory. Definitely a problem.

I am facing same issue. But weird thing is if I edit .gitignore and save the file. It starts greying out correct files and folders!

@joaomoreno I believe the following should be reproducible: files that are ignored by global ignore rules. I have some rules in the projects .gitignore which are greyed out correctly, but rules that are added in my ~/.config/git/ignore are not greyed out.

Actually, never mind. Just switched to a new project and it is greyed out via the global ignore. This bug is hard to pin down! (still happens to my other larger project)

Are any of you, perhaps, running with the Remote WSL extension? Because I am and I'm not sure if it's related or not.

For me, grayed-out items and also colored items (Git status) on the explorer tree don't seem to work with a project opened with the Remote WSL extension. If I open this folder locally, everything is colored properly. Also, changing and saving .gitignore produces UI changes with the project folder opened locally but not with Remote WSL.

And yes, Git is working inside WSL in both instances. However, local projects are using Git for Windows while Remote WSL projects are using Git installed in WSL.

same problem here today, locally .gitignored files and directories are not grayed out (I have no globally ignored stuff, I think).

Facing the same issue. gitignored files except node_modules are not greyed out.

They also show up in Source Control which is kind of annoying.

Had the same issue - this was because my project was on a symlinked folder. Moved it to a non symlinked folder and it worked bueno.

VSCode isn't properly interpreting .gitignore. I have a subfolder in my repo called icons-and-symbols, and a .gitignore at the top level (one level up) with the line

icons-and-symbols/.xdignore

but it's not ignoring that file for CHANGES, nor is it grayed out the file explorer.

Same here, on a Go + Bazel project.

Note: I've tried building VS Code from source; the issue does not reproduce (even on the same version 1.39.2).
This probably has something to do with the build parameters. Maybe too much data fed into git check-ignore?

I started running into this issue today, out of the blue. I made no changes that could obviously have caused it.

Are any of you, perhaps, running with the Remote WSL extension? Because I am and I'm not sure if it's related or not.

I am and that seems to be the issue. Anyone found a fix or workaround?

I am too.

I'm not using a WSL and still facing the issue sometimes

Just saw it on my OSX build. Modifying the .gitignore and re-saving fixes it.

I'll double what @derekju said, opening and saving the .gitignore file seemed to fix it.

I ran into this issue when I updated to the October release. The project I had open before I did the update was not showing the grayed out files after it (even after doing Developer: Reload Window). I opened .gitignore and hit save, no modifications needed. After that all the proper files were grayed out and persist as expected after Developer: Reload Window

Alas saving and reloading .gitignore has no effect for me, whether I run Developer: Reload Window or not.

My situation may be related but different: the issue I experience manifests with project directories that are (git) submodules of other git repositories. In these cases, .git is expressed on disk as a text file containing the gitdir attribute which points back to the actual repository. It seems that even though .gitignore is present at the root of my project directory, it is not loaded. So no directories being ignored / greyed out.

Same issue.
Re-saving .gitignore helped with untracked files, but newly untracked did not work.
So i cleared my git cache and re-added the files and re-committed. Then re-saved .gitignore once again and it is working now.

Clearing Git Cache:

git rm -rf --cache .
git add --all
git commit -m 'Cleared Caches'

Then re-save .gitignore

I just had the same problem after pulling a project with an updated .gitignore. Solved with a simple save on the .gitignore file.

I had the same issue and I solved it. The problem lied in the folder being opened by a symlink (ln -s). Opening the folder with the File -> Open... fixed the issue for me. This also caused some delays with changes appearing in the source control tab.

I am used to opening VScode projects using the code command in my mac's Terminal to speed up the process. Doing so, the greying-out functionality does not work. To have it, I have to firstly open VScode, then using the File -> Open find my project and open it. It takes about 5 times longer, so it would be very nice if the .gitignore feature worked for projects opened with code as well.

Problem still present in latest VSCode (as of when I made this post). I am on Windows and nothing special about the project. Making a benign edit to .gitignore and saving it seemed to fix the issue as others have reported.
2020-04-13

Just a note, closing and then re-opening the project resets to the incorrect (bad) behavior of not marking the ignored items "inactive".

Re-saving the .gitignore file, even without changing anything in it, makes explorer properly grey-out files again.

@egorovli Sure, but why would I want to have to do that every time I switch projects? I'd rather have the bug squashed. :(

@bramankp I’m not saying it shouldn’t be fixed, just giving the developers more info on this bug’s behavior, as well as giving other people facing the same issue advice on fixing it in-place a little bit faster than reloading window.

Same issue.
Re-saving .gitignore helped with untracked files, but newly untracked did not work.
So i cleared my git cache and re-added the files and re-committed. Then re-saved .gitignore once again and it is working now.

Clearing Git Cache:

git rm -rf --cache .
git add --all
git commit -m 'Cleared Caches'

Then re-save .gitignore

I had the same issue (file not getting greyed out and still being tracked for changes + pushed to remote) and this was the only thing that worked for me. Reloading window, closing and opening vscode, saving .gitignore in the editor etc all did nothing.

Just noticed the same issue here, with the latest Insiders version:
Version: 1.47.0-insider
Commit: 84f52fe1c0124307046ac0f5443493cda946e60f
Date: 2020-06-17T06:56:23.406Z
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 19.5.0

Doing a Reload Windows brought back my gitignored coloring of folders. I do not have the WSL Remote extension, nor is anything symlinked.

I know this is a bit of an older issue, but I am still seeing this on the main release. Does not serve any functional difference, but still sometimes spooks me into thinking files that shouldn't be committed had been.

I have it happening consistently in one of my larger projects: no matter what I do, this particular project never has it working. Unfortunately, this project is private and I cannot share it but would be happy to provide some files if any in particular if it helps for resolving this.

Works fine in just about any other repo I open with the same VSC configuration. Slightly modifying the .gitignore as mentioned above had no effect.

VSC:

Version: 1.48.0 (system setup)
Commit: db40434f562994116e5b21c24015a2e40b2504e6
Date: 2020-08-13T07:50:42.600Z
Electron: 7.3.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18362

My .gitignore here is a gitignore.io windows,visualstudiocode,node,react template with the following two lines added to the bottom:

packages/*/lib/
packages/*/data/

A quick look in the VSC output tab, and there's a Git error that prints every time the window reloads in both Log (Window) and Log (Extension Host):

[2020-08-19 19:44:22.499] [exthost] [error] {"message":"Git error","stdout":"","stderr":"fatal: c:\\path\\to\\project: 'c:\\path\\to\\project' is outside repository\n","exitCode":128}

Hope this helps to track this down. Happy to provide any other info.

Edit: There are also some symlinks, though only those added by Yarn workspaces. Have not had any issues with this feature of Yarn and this feature of VSC conflicting in any other projects, however.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sirius1024 picture sirius1024  Â·  3Comments

shanalikhan picture shanalikhan  Â·  3Comments

villiv picture villiv  Â·  3Comments

lukehoban picture lukehoban  Â·  3Comments

sijad picture sijad  Â·  3Comments