3

Files with the red "minus" with status "ignored" are being listed in the Solution Explorer. How do I automatically remove them?


This is related to temp files created by Office programs, but seems to apply to any file excluded by gitignore. Note: this is for Visual Studio, not VS Code, otherwise an extension like "hide-gitignored" would be ... better than nothing.

This is not (I don't think) a problem with .gitignore. Running git rm -r --cached . and git add . doesn't change anything (e.g., this question ). The files are ignored and running git check-ignore -v verifies the files are being ignored by git (e.g., this question ).

Visual Studio seems to identify that the files are ignored (see the red "minus" icon):

showing red minus icon

Documentation suggestions .gitignore should be automatically picked up by Visual Studio, but there's no "Repository Settings" available (Visual Studio Professional 2019, 16.8.4).

enter image description here

I can right click an individual file and choose "Exclude From Project" and the file will be hidden. But if a new Office file is ever added to the project, you will have to open the file (so the temp file will exist on disk), then exclude the new temp file. The expectation is that .gitignore would be applied automatically.

Note that this isn't limited to just Office files, this is any file excluded by gitignore.

.gitignore:

# NUNIT
*.VisualState.xml
TestResult.xml

# office temp files
~$*.xlsx
~$*.docx

And then creating a new file called TestResult.xml (and unloading/reloading project):

enter image description here

BurnsBA
  • 4,347
  • 27
  • 39
  • FWIW : it is normal for an IDE to display all files present on your *disk*. A file, for example a code file generated from something else, may be ignored in a git repo and still be important to the behavior of your project/solution. You should look into how to make your Visual Studio *solution* overlook files. (I'm not running Windows, I wouldn't know how to guide you in Visual Studio settings, though) – LeGEC Apr 06 '21 at 22:47

0 Answers0