Visual Studio is not recognizing git repo

14.7k views Asked by At

Upon opening my ASP.NET Core project with an existing git repo in Visual Studio 2022, the git repo is not being loaded. However, opening a freshly cloned repo of this project from GitHub works fine. And opening other projects with git repos work fine. What could be the issue?

5

There are 5 answers

1
Abhi On

I ran into the same problem.

Visual Studio Code and Git bash correctly recognized the repo but not Visual Studio 2022.

I installed the latest version of Git in the system, and the visual studio recognized the git repo correctly.

2
patriml On

Had the same issue after upgrading to latest version of VS2019 and had a look at the output from "Source Control - Git", there were messages of a fatal error because of no access and suggesting running the following:

git config --global --add safe.directory path/to/repo

After running it and restarting VS2019 it works OK.

1
maze On

Had the same problem running VS2022 under Win10. Problem was that the ownership of the file system directory containing the solution and git data had changed to Administrator. After changing the ownership back to my normal windows user account everything worked fine again.

2
Andrey Sv On

In my case the project was cloned in console with Administrator rights. All worked good in console but Visual Studio was not read the .git folder.

Actually folders has enough rights for Authenticated Users group that was assigned for all child objects but Visual Studio still not see .git folder.

Only after change owner of project folder and all child objects to current account Visual Studio seen .git

Steps:

  1. Open Properties of project folder.
  2. On tab Security select button Advanced.
  3. Select tab Owner and button Change.
  4. In List select your account plus check "Replace owner on subcontainers and objects".
  5. Click Apply
4
dpdragnev On

If you run VS 2022 as an Administrator, it should load everything as it should.