'Git has stopped working after installing VS 2022

After installing the new Visual Studio 2022 the built-in Git support has suddenly stopped working. For one of the projects I am seeing only a submodule instead of the main repository. For another project the built-in Git panel doesn't appear at all, displaying some cryptic message about "SccProviderPackage" stating that "One or more errors occurred" as a reason...

Spent a while following every single advice I could find about similar issues with no luck.



Solution 1:[1]

In the end I had decided to give up and try Git Extensions from GitHub instead. There I finally see the exact error message (for some reason, it was in the "Remotes" list instead of the actual list of remotes, but at least it was there).

The cause was that Git didn't consider directories with my repos "safe". So the solution is to add your repositories to the safe directories using the following command:

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

Hope this helps someone who will be stuck with this issue like me.

Solution 2:[2]

I had the same problem after updating to 17.1.5. I checked the ownership of the folder of my local repository and my project (Working Tree). Setting the ownership to myself fixed the problem.

TO DO THIS:

  1. Right-click on the folder containing the working tree and .git folder.
  2. Click Properties
  3. Go to tab Security.
  4. Click the Advanced button.
  5. Click Change for the owner.
  6. Select your user name.
  7. Check Replace owner on subcontainers and objects.
  8. Click Apply and Ok.

VS can then open the local repository.

Solution 3:[3]

Opening the VS in admin mode solved the issue for me. Hope that helps.

Solution 4:[4]

I noticed that the owner of the folder containing .git has been set to a missing account! So I changed the owner to myself and the problem was solved.

Solution 5:[5]

I explicitly set the owner of the folder containing the working dir and .git folder as my user, using inheritance for everything in it.

As @Code-Apprentice noted, this is linked to Git v2.35.2 that

changes Git’s behavior when looking for a top-level .git directory to stop when its directory traversal changes ownership from the current user.

As @mephisto123 realized,

If you wish to make an exception to this behavior, you can use the new multi-valued safe.directory configuration

Solution 6:[6]

All other suggestions in this question did not work for me.

Believe it or not, I think I tracked this down to having VS2022 pinned to Taskbar and set to launch as Admin (via right click Properties>Advanced). Once I disabled the admin launch then the Git Changes window began working. I can launch VS2022 as Admin but need to do that manually via right click Run As Administrator.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mephisto123
Solution 2 Arman
Solution 3 Sonu K
Solution 4 Pedram Aghazadeh
Solution 5 user276648
Solution 6