microsoft / vscode

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

VS Code is tracking Git ignored files #154885

Closed SujithChristopher closed 1 month ago

SujithChristopher commented 2 years ago

Issue Type: Bug

I have a problem, whenever i exclude files using gitignore vscode is tracking changes in those files.

This does not happen in pycham, only in VS Code

image

VS Code version: Code 1.69.0 (92d25e35d9bf1a6b16f7d0758f25d48ace11e5b9, 2022-07-07T05:28:36.503Z) OS version: Windows_NT x64 10.0.19044 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-8700T CPU @ 2.40GHz (12 x 2400)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|15.83GB (4.37GB free)| |Process Argv|--crash-reporter-id 6604b41d-4549-43d1-ba22-1f5525371cb2| |Screen Reader|no| |VM|0%|
Extensions (19) Extension|Author (truncated)|Version ---|---|--- doxdocgen|csc|1.4.0 copilot|Git|1.31.6194 gc-excelviewer|Gra|4.2.55 better-cpp-syntax|jef|1.15.19 kite|kit|0.147.0 git-graph|mhu|1.30.0 vscode-docker|ms-|1.22.1 csharp|ms-|1.25.0 python|ms-|2022.10.0 vscode-pylance|ms-|2022.7.20 jupyter|ms-|2022.6.1001902341 jupyter-keymap|ms-|1.0.0 jupyter-renderers|ms-|1.0.8 remote-containers|ms-|0.241.3 cmake-tools|ms-|1.11.26 cpptools|ms-|1.10.8 cpptools-extension-pack|ms-|1.2.0 platformio-ide|pla|2.5.0 cmake|twx|0.0.17 (1 theme extensions excluded)
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 pythonvspyl392:30443607 vserr242cf:30382550 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 pythondataviewer:30285071 vscod805:30301674 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 vsc1dst:30438360 pythonvs932:30410667 wslgetstarted:30449410 vscscmwlcmt:30465135 cppdebug:30492333 vscaat:30438848 pylanb8912:30520716 vsclangdf:30486550 ```
raysuelzer commented 2 years ago

Can confirm this is also occuring in the following version. Easy to reproduce. Update gitignore to exclude some files (ideally nested in a directory). Commit gitignore. Make changes. Strangely it even lets me commit the file! It only seems to happen with any files or patterns that were not already in gitignore when i pulled the branch.

This is a bit of an issue as it makes it easy to commit secret keys etc.

image

EDIT: Sorry, this is a fundamental misunderstanding of how gitignore works. Since I was already tracking the files there is no way to ignore future changes without deleting them (at least from the github cache) using git rm --cached. I suppose what I wanted to do (have a default template file in the repo, where a user would make their instance specific changes, but that would not be checked in or tracked, is not possible.

wuhkuh commented 1 month ago

It's a limitation of Git. What might work for you is git update-index --assume-unchanged <FILE_PATTERN>.

This issue can be closed.