microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.43k stars 28.95k forks source link

.gitignore'd files sometimes not greyed-out #70963

Open egorovli opened 5 years ago

egorovli commented 5 years ago

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 😞

joaomoreno commented 5 years ago

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

jrieken commented 5 years ago

Anything changed recently?

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

rendomnet commented 5 years ago

Same here gitignore not graying folders and files

dacioromero commented 5 years ago

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

eclectic-coding commented 5 years ago

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.

ghost commented 5 years ago

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!

shadow-light commented 5 years ago

@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.

shadow-light commented 5 years ago

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)

rfgamaral commented 5 years ago

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.

carlodri commented 5 years ago

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

sebastiantf commented 5 years ago

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.

marzukia commented 5 years ago

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.

cpryland commented 5 years ago

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.

kyegupov commented 5 years ago

Same here, on a Go + Bazel project.

kyegupov commented 5 years ago

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?

brunoparga commented 4 years ago

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

pmonty commented 4 years ago

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?

rfgamaral commented 4 years ago

I am too.

sebastiantf commented 4 years ago

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

derekju commented 4 years ago

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

jjspace commented 4 years ago

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

pospi commented 4 years ago

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.

ggedde commented 4 years ago

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

LasaleFamine commented 4 years ago

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

nickelghost commented 4 years ago

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.

drzamich commented 4 years ago

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.

bramankp commented 4 years ago

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

bramankp commented 4 years ago

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

egorovli commented 4 years ago

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

bramankp commented 4 years ago

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

egorovli commented 4 years ago

@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.

alastairvox commented 4 years ago

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.

jtsom commented 4 years ago

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.

CynicalBusiness commented 4 years ago

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.

marioessig commented 3 years ago

Solution: save on .gitignore file and this will update the .gitignore file and then gray out the files.

MakePixelsWork commented 3 years ago

I also have this error. I tried saving, even on top of the old file, by overwriting it, but the files are still not grayed out.

image

Version: 1.53.2 (user setup) Commit: 622cb03f7e070a9670c94bae1a45d78d7181fbd4 Date: 2021-02-11T11:48:04.245Z Electron: 11.2.1 Chrome: 87.0.4280.141 Node.js: 12.18.3 V8: 8.7.220.31-electron.0 OS: Windows_NT x64 6.3.9600

crystalfp commented 3 years ago

I'm on windows and the procedure suggested by @ggedde (clearing git cache and resave .gitignore) solved the problem! Thanks a lot!

jonagoldman commented 3 years ago

I found setting "explorer.decorations.colors": true fixed the issue. Other suggestions like clearing git cache and saving .gitignore did not solved the problem for me.

danieldupree commented 3 years ago

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.

This was the fix for me.

huzaifahj commented 2 years ago

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

This worked for me. Looks like newly untracked files need to be taken into account

marcitqualab commented 2 years ago

[solved] I had this error of not greying out the files and directories registered in .gitignore. I am using Ubuntu 20.x. I have a symbolic link at the home page to the projects folder that is actually inside a deeper structure of directories. Tell me I am a complicated mind, I know. Adding the folder to the workspace using the symbolic link was the problem in my case. Solution.

  1. Remove de folder from the workspace.
  2. Add folder to workspace, NOT using the symbolic link, but the actual full path to the folder.
lts20050703 commented 2 years ago

Both VSCode and VSCode Insider stop grayed/greyed out files (and color and indicator yellow M etc...) so I tried WSL and it works There's probably something wrong with VSC Windows Note: I am using the System installer, not sure if that's related

marcitqualab commented 2 years ago

I suspect that most of the problems would be somehow caused by loading a project folder from a "non-real", "non-local" file system. i.e symbolic links, virtual volumes or similar things.

ggedde commented 2 years ago

I might create a separate issue for this, but it would be nice if clicking on the Refresh icon or refreshing the folder list would also force update the VSCode internal GIT checks. The idea is that it would resolve this issue and also another issue where sometimes I run GIT commands from the terminal and VSCode does not recognize the changes and still shows items as changed and not committed, etc

This isn't a full solution, but since this issue has been around for almost 3 years, I think this would be a good compromise until it is fully resolved.

Thoughts?

id-matt-michler commented 2 years ago

In case this helps anyone else, updating my version of git fixed this for me. I upgraded from 2.16.2.windows.1 to 2.36.0.windows.1, I'm usually on WSL so I didn't realize how far behind my Git for Windows was.

vuongvinhvien commented 2 years ago

It work for me: use cmd or git bash... and type: "git config --global --add safe.directory D:/project" change "D:/project" to your path or just D:/

mdotcoder commented 2 years ago

In my case, it was the .env file that was not greying out. Solution for me, I deleted the .env file and readded it. It immediately greyed out.

vaspoz commented 2 years ago

tried all of the suggestions from above, but nothing works =\ is it still the issue? VSC version: 1.71.2

vipiny35 commented 2 years ago

I had the same issue, it only happens when you open a project which is a symlink folder. Directly opening the folder in vscode didn't have any greying out issue.

KittPhi commented 1 year ago

My fix was to Restart VS Code and then Resave .gitignore

Issue stemmed from upgrading Mac OS to Ventura. That error and fix are below.

Initial error:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

Fix:

xcode-select --install