After updating Visual Studio 2022, projects no longer under Git control
Asked Answered
B

9

19

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?

Buckram answered 15/4, 2022 at 21:24 Comment(1)
This issue is under investigation at MS. You can vote for and follow here: developercommunity.visualstudio.com/t/…Buckram
S
7

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.

Storiette answered 20/4, 2022 at 9:42 Comment(1)
May not be the correct solution for large enterprise networks but when can you see that the previous developer is the owner of the directory, this is the fast and simple solution.Seigneur
U
6

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.

Ursal answered 16/4, 2022 at 8:51 Comment(3)
Confirmed - this solution works for me as wellBuckram
Not working for me. One note: my solution is on a different drive (D) then my git install location (C)Mam
Worked for me as well. This is how you always open VS as admin: #9655333Gloucestershire
H
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

Hermit answered 17/4, 2022 at 6:17 Comment(1)
I tried "Run as administrator", "git config --global --add safe.directory /path/to/repo " and other asnwers but only install Github desktop and add local respository to it worked.Accessary
A
2

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.

Adamo answered 16/4, 2022 at 13:52 Comment(0)
C
2

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
Condolence answered 17/4, 2022 at 13:30 Comment(0)
I
1

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.)

Interact answered 16/4, 2022 at 7:33 Comment(0)
C
1

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'/'.

Cobbie answered 18/4, 2022 at 1:23 Comment(1)
Make sure you don't include a trailing slash otherwise won't work. For example, git config --global --add safe.directory C:/Users/Public/repos works but git config --global --add safe.directory C:/Users/Public/repos/ does not. The latter will get added to the config but you might still get errors in Visual Studio.Polacre
C
1

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

Coseismal answered 18/4, 2022 at 10:5 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Schnorr
C
0

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.

Capitular answered 16/4, 2022 at 17:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.