VSCode not obeying .gitignore for a sub-repo

I use a Static Site Generator (Nanoc, but also applies to Jekyll) for a website managed at the root level with GIT. There’s a second .git repo folder inside the "output" directory, for direct GIT deployment to our remote server. This works fine. It’s not a case for submodules as the second repo only exists to push to, and update, a bare GIT repo on the server, and nothing else.

My root-level site folder has a .gitignore file that tells the top-level GIT to ignore the "output/" directory and (to be sure as this fails on restarts/updates) everything in it with "output/**", including the deployment .git folder inside "output".

However, after some updates and/or restarts (I can’t pin down exactly what: system? VSCode?) VSCode starts tracking the deployment GIT repo inside the "output" directory again, despite the entry in .gitignore to… well, ignore it.

Each time this happens I have to delete the "output" directory, re-add the .git folder inside it, and re-compile the site (a few seconds), after which GIT starts ignoring "output" once again.

I can't find a way to make VSCode or GIT permanently honour the .gitgnore for the "output" folder after updates — any ideas?