18

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.

7 Answers 7

24

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.

4
  • 1
    Thx. It's work. Project-folder owner must be exactly current user (Groups: Administrators, All etc didn't work). Also it can be done from cmd: takeown /f projectfolder /r /d y
    – Geograph
    Apr 22, 2022 at 14:10
  • 1
    It worked like a charm. Previously I had updated git and added project to safe directories without any luck. The only workaround was to open VS as an administrator. Thanks! May 7, 2022 at 14:46
  • this worked for me. the dev folder owner was some weird long string (a guess - it was set during the upgrade of Windows from 10 to 11, although I cant be sure) May 10, 2022 at 19:32
  • 1
    Open bug: developercommunity.visualstudio.com/t/…
    – kitsu.eb
    May 23, 2022 at 14:04
16

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.

2
  • 2
    This issue is the result of a security update to git addressing CVE-2022-24765. Here's one source I found: github.blog/2022-04-12-git-security-vulnerability-announced. Feel free to do additional research if you are interested in learning more. Apr 16, 2022 at 4:24
  • 2
    @Code-Apprentice Correct, that's what I found out after spending a whole day trying to figure out what is the underlying issue because MSVS doesn't provide any information about it... Apr 17, 2022 at 5:07
8

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

3
  • 2
    Maybe your .git folder is owned by your admin account and you need to change its owner to your own account to be able to use VS with your user.
    – user276648
    Apr 18, 2022 at 3:59
  • Hurray! This did it for me! I have many different repos under the same directory structure, but only this one project has this issue. Interestingly, this issue goes away (as non-admin) once I clone the repository back down to my local machine, but upon opening the solution more than once, the issue comes back.
    – Prethen
    Apr 28, 2022 at 20:55
  • this didnt work for me. the overriding of the owner did. I guess the difference is that my Windows was an upgrade from 10 to 11 and the owner of the dev folder was some weird long string (another guess - it was set during the upgrade although I cant be sure) May 10, 2022 at 19:30
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.

1
  • this worked for me, thanks Apr 22, 2022 at 9:23
2

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

0

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.

0

For me it worked by updating git version using

git update-git-for-windows

and updating owner of repository by following first answer @Aramn from this page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.