So, I'm not sure when exactly this happened or what happened, but it looks like new .git repositories aren't being detected by either Visual Studio or VS Code. This is happening specifically for VS 2022 solutions I've created recently, but haven't had issues with in the past. I have a repo in the solution folder of my project and the Git Changes window doesn't see that (instead it defaults to the .git folder that is the parent of the one housing the solution folder). When I use VS Code to open a folder in it and use the Git Lens Supercharged plugin, it doesn't find a repository at all even though there's a .git folder plain as day in the directory.
My only guess is that the issue is related to a .git folder created at the main directory level that contains other directories that have projects in them each with their own .git repo's, yet these repositories are found just fine by VSCode.
I'm at a loss here and am so baffled I'm not even sure what more I can say to explain the situation. Any thoughts, suggestions, and/or questions would be welcome. Thanks!
Here's my directory structure. This is a REALLY simplified version of it:
wwwroot (has .git repo that includes just the files (not folders) under it)
----- Project 1 (Not a VS project, but has a git repo that VS Code locates)
----- Project 2 (VS 2022 project. Neither VS Code nor VS 2022 seem to be able to see it)
----- File A (part of wwwroot's repo)
----- File B (part of wwwroot's repo)
EDIT 1
I don't think this is using submodules. I don't see a .gitmodules file.
Also of note, git commands within CMD work as expected. I was able to add files, commit files, remove directories, and push to our Azure DevOps server.
EDIT 2
If I try to open the repository in question with Git GUI (the windows app), I get the following error:
fatal: detected dubious ownership in repository at 'c:/root/projectPath'
'c:/root/projectPath/.git' is owned by: 'S-1-5-##-###' but the current user is 'S-1-5-##-#########################'.
To add an exception for this directory call:
git config --global -add safe.directory c:/root/projectPath
I haven't tried modifying the global git config yet because I'd like to know what this command is telling me.
EDIT 3
Okay, so it looks like when I run CMD as an admin and init a git repo, VS Code and other tools see that git folder owned by a different user than the current user. I get that same error from my EDIT 2 section. This at least sort of explains part of that.
Yet, if I delete that .git repo I just created and open the folder with VS Code, I can initialize a new git repo via Git Lens. Before VS Code really didn't see the repo and gitlens just displayed the option to initialize a repo or connect to an existing one.
I tried rebooting as it has been a few days, but that didn't resolve anything.