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 😞

s-williams commented 1 year ago

Had the same problem today in version 1.73.1 on Windows 10. Restarting VSCode fixed it. 👍

SachinShekhar commented 1 year 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!

@sulaysumaria Wow! Such an elegant solution. 🔥🔥🔥

direc85 commented 1 year ago

I'm hitting this on daily basis with 1.76.0 on Manjaro Linux. Re-saving .gitignore doesn't usually help, restarting vscode helps, but is inconvenient.

The setup I have is having a project/git repo folder opened in vscode, and the project has a subfolder which has other repositories as its subfolders. When I open vscode and the folder, there's correctly only one repo in Source Control. If I open a file in a subfolder repository, the .gitignored folder gets picked up by vscode and Source Control, and folder gets colored there are now two repos in the side bar tab. After that, the only way to make the folders be ignored again is to restart vscode.

To illustrate:

project-folder (git repo)
|- .gitignore (contains "subfolder/project-*")
|- subfolder
|  |- project-a-folder (git repo)
|  |  |- file-a.txt
|  |- project-b-folder (git repo)
|  |  |- file-b.txt
|- (more files)

The coloring and Source Control work as expected as long as I don't touch file-a.txt or file-b.txt having the root project opened. So I guess in this particular case the culprit is the Source Control picking the file up, bypassing the root project .gitignore.

There are reasons why we can't use the repositories as submodules, which might solve both issues as well, but our workflow sadly doesn't support that.

wmmc88 commented 1 year 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.

This was the issue for me. When the path of the folder opened includes a symlink, the greying out of .gitignored files breaks.

neodon commented 1 year ago

I have this problem on Windows 10 (using Remote SSH extension with a Linux VM). It happens when I first open a VSCode window and resolves if I reload the window. None of the other suggestions apply.

I also have the problem on MacOS, except there doesn't seem to be any way to resolve it.

awalker125 commented 1 year 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 fixed my issue. I'd made a junction to move my workspace folder to D:\ while keeping the same structure as everyone else on C:. When I deleted the junction and moved my workspace back to C:\ it started working straight away.

jgardona commented 10 months ago

I can confirm this issue today in linux, in my project also. Happens all the time.

image

virtuallyunknown commented 9 months ago

Same issue here. Reloading VSCode or re-saving .gitignore does not fix the problem.

vaspoz commented 9 months ago

@jgardona, /target I see is working, did you try with the file to also use / in front?

jgardona commented 9 months ago

@jgardona, /target I see is working, did you try with the file to also use / in front?

I'll try and return with a feedback.

vd1371 commented 9 months ago

Same problem, I opened the repo with "Open Folder" Then I saved the workspace in .vscdoe folder in the root folder and opened it using "Opened Workspace From File..." Solved it for me

joshgalvan commented 9 months ago

Restarting VSCode solved this for me

montythepython commented 8 months ago

A solution for some that havent been able to solve it with any of the answers given above: I am working in WSL but I think this should be independent of this.

If you have already commits and then add files to gitignore, they will not be ignored (they will not grey out). Move the files/folders you want to ignore out of the repository folder (keep them listed in your gitignre file). Do a git add . and then commit. Now you can bring the files/folders back into the repository folder and if they are properly listed in your gitignore file they will be greyed out after you do another git add/commit/push

In theory git rm --cached should do it but for some reason it didnt work for me

montythepython commented 8 months ago

Hey @neodon , what about explaining why you add thumbs down to comments here if these solutions are working for some people? You are aware that gitignore does not ignore files already commited, right?

neodon commented 8 months ago

@montythepython This issue relates to a bug in VSCode causing files and folders in .gitignore to sometimes appear greyed-out and sometimes not. It's not a user mistake of having a committed file that's in .gitignore, which would never appear greyed-out.

montythepython commented 8 months ago

@neodon great, thanks for the explanation. In my case I had some greyed out from the past and it seemed to be linked to the files in the gitignore file. I didnt notice if they were not greyed out earlier or if they had changed back and forth. I thought that they simply got grey if they were in the gitignore file. When I added new files to gitignore and they didnt greyed out, I started reading about it and ended up in this github page.

After reading about it, I did what I explained in my post and the new files that I added in the gitignore turned grey, so I thought I had made it worked. Currently all the folders I have in gitignore are greyed out and the rest are not.

If they change later on, I will post again with an update.

Thanks for the explanation

vaspoz commented 8 months ago

@montythepython , oh man, you should have named yourself MightyPython! =)

TheRealMikeD commented 8 months ago

Still experiencing this issue in February, 2024. @ggedde's technique of clearing the git cache worked for me, after nothing else did. And then it came right back after modifying another file.

App Info: Version: 1.86.1 Commit: 31c37ee8f63491495ac49e43b8544550fbae4533 Date: 2024-02-07T09:09:01.236Z Electron: 27.2.3 ElectronBuildId: 26495564 Chromium: 118.0.5993.159 Node.js: 18.17.1 V8: 11.8.172.18-electron.0 OS: Darwin x64 21.6.0

yaa110 commented 6 months ago

same issue here:

Version: 1.87.2
Commit: 863d2581ecda6849923a2118d93a088b0745d9d6
Date: 2024-03-08T15:14:59.643Z
Browser: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Code/1.87.2 Chrome/118.0.5993.159 Electron/27.3.2 Safari/537.36
TheRealMikeD commented 5 months ago

Still broken in 1.88.1.

kturney commented 2 months ago

This wasn't working for me on a new install/machine setup. Changing git.openRepositoryInParentFolders to always (from never) and suggestion from https://stackoverflow.com/a/65885419 to

run git fetch --all in CMD inside the project directory

fixed it for me.