I am using Git for Windows version 2.34.1 x86. I have a folder with the following contents (all path names are relative to that folder):
.git/
.gitignore
.vs/OS1/FileContentIndex/a
.vs/OS1/v17/Browse.VC.db
.vs/OS1/v17/Solution.VC.db
.vs/OS1/v17/ipch/AutoPCH/a
econv.txt
As we can see, the folder itself is under Git control. However, none of the files or folders shown above have ever been staged or committed yet, except .gitignore
, which is already tracked.
I am unable to understand the different behavior of git status
vs. git check-ignore
in the following two situations:
Situation 1
.gitignore
has the following content:
/.vs/**/
!*/
git status
outputs (shortened to the interesting part)
Untracked files:
(use "git add <file>..." to include in what will be committed)
.vs/OS1/FileContentIndex/
.vs/OS1/v17/Browse.VC.db
.vs/OS1/v17/Solution.VC.db
.vs/OS1/v17/ipch/
econv.txt
git check-ignore -v .vs/OS1/FileContentIndex/
outputs
.gitignore:3:!*/ .vs/OS1/FileContentIndex/
which means that .vs/OS1/FileContentIndex/
is not ignored. This is consistent with the above output of git status
. So far, so good.
Situation 2
.gitignore
has been changed minimally and now contains
/.vs/**
!*/
git status
outputs (shortened to the interesting part)
Untracked files:
(use "git add <file>..." to include in what will be committed)
econv.txt
git check-ignore -v .vs/OS1/FileContentIndex/
outputs
.gitignore:3:!*/ .vs/OS1/FileContentIndex/
The question
I understand the behavior in situation 1. git check-ignore .vs/OS1/FileContentIndex/
tells me that .vs/OS1/FileContentIndex/
is not ignored, and therefore git status
puts it into the list of untracked files (it has not been added, staged or committed yet).
But I am unable to understand the behavior in situation 2. Here, git check-ignore .vs/OS1/FileContentIndex/
yields literally the same output as in situation 1, which again means that .vs/OS1/FileContentIndex/
is not ignored.
However, git status
does not have it in the list of untracked files any more. This seems inconsistent to me, because it should appear in the list of untracked files if it is not ignored, shouldn't it?
Could somebody please explain what is going on there?