'After updating Visual Studio 2022, projects no longer under Git control

Ran Visual Studio Installer for the following:

  1. Added 'Desktop Development with C++'
  2. Updated VS to the latest version 17.1.4

Now when I load any project, it is no longer under source control. In the Git output window, I get a very helpful "One or more errors occurred".

enter image description here

Using the Bitbucket as source control provider.

I've tried going to the Git menu and the only enabled options are to create a repo or connect to a local repo. I've tried connecting to local with no results.

Is there a way I can find out what the errors are?



Solution 1:[1]

I cannot connect to git repo and get the "One or more errors occurred" message in the Git output after updating VS to 17.1.4 - on only some of my repos, not all. I do not use the Atlassian Bitbucket source control service.

When running VS 2022 'as administrator' connection to the git repo is possible without errors.

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]

Problem is solved. 1- first install GitHub Desktop 2- add local your repository to GitHubDesktop 3- All Done. now open project in visual studio

Solution 4:[4]

Had the same issue. Seems linked to a security update of GIT (see article).

The problem had several phases on my side.

  • Did not update GIT but VS to 17.1.4 and had the problem in the IDE but CLI worked.
  • Found this info above and updated GIT. Problem did persist in VS and CLI explicitly asked me to type a command. git config --global --add safe.directory /path/to/repo which worked to unlock the feature on both CLI and VS.

So git update or git update-git-for-windows in CLI. That may not be necessary but I did reboot.

Solution 5:[5]

I ran the following command and my issue is now resolved.
Open cmd then run the following:

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

Solution 6:[6]

Yep Git from inside Visual Studio is broken here since updating VS. Updated Sourcetree Git, System Git, Deleted then Re-Created repo etc. same continuous error: "One or more errors occurred."

I am going back to sticking with doing SCC in Sourcetree from outside of VS and wait for a fix - or not - as the case may be.

FYI: its only a local repo without remote: maybe something to do with getting the credentials stored by Sourcetree in the Windows Credential Store i.e. credential helper or something..

(There are much much better Software Dev things to do than wasting time trying to fix someone else's dodgy SCC interop tool: coughs (Microsoft) and coughs again.)

Solution 7:[7]

I faced the same issues when VS2022 was updated to version 17.1.14. The solution from @Ken Bonnin Jr can solve this problem. For the details, I have to run the following code in each location included .git file.

git config --global --add safe.directory %(prefix)/Path

Path is the address at .git file with symbol'/'.

Solution 8:[8]

it weird i just update git and ran as administrator problem solved

Solution 9:[9]

I tried both of the suggestions by @UchiTesting and got some success with our github hosted repositories. My original code folder worked fine until 17.1.4.

This appeared to reconnect VS and github again:

  • Launch VS 17.1.4 as Administrator
  • Menu > Git > Clone Repository to a new folder
  • Note the repository information is correct
  • Close VS and relaunch as Administrator
  • Open the solution file directly

The repo and branch info appear to be retained in VS 17.1.4 on the clone, but only as Administrator. Opening this new clone as non-Administrator does not appear to bring the same results.

Regarding the original folder that stopped working after the 17.1.4 upgrade (and I always run as Administrator), I followed the steps with both git update-git-for-window and git config --global --add safe.directory /path/to/repo.

Opening the original folder as Administrator now remembers git info.

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 Kathleen
Solution 2 Arman
Solution 3 Omital
Solution 4
Solution 5 Reza Rahemtola
Solution 6 mattjs
Solution 7
Solution 8 Forsandy Kurniawan David
Solution 9