Git has stopped working after installing VS 2022
Asked Answered
R

7

20

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.

Radke answered 16/4, 2022 at 4:19 Comment(0)
R
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.

Radke answered 16/4, 2022 at 4:19 Comment(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.Kingcup
@Kingcup 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...Radke
E
26

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.

Eclampsia answered 20/4, 2022 at 9:39 Comment(3)
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 yBenedictine
Open bug: developercommunity.visualstudio.com/t/…Thinskinned
Had this happened due to running git clone from elevated (Admin) command prompt. Had to change ownership to the exact user I use to login, even though the user is a member of local admin group.Raynata
R
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.

Radke answered 16/4, 2022 at 4:19 Comment(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.Kingcup
@Kingcup 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...Radke
V
9

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

Vela answered 16/4, 2022 at 20:2 Comment(3)
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.Tonga
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.Pooley
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)Deneb
A
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.

Abshire answered 21/4, 2022 at 19:10 Comment(0)
T
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

Tonga answered 18/4, 2022 at 1:53 Comment(0)
A
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.

Aras answered 9/5, 2022 at 15:42 Comment(0)
B
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.

Blip answered 28/9, 2022 at 14:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.