8

I have been using git in VS 2019 CE for 2yrs without any problems. I have just installed VS 2022 and git doesn't seem to work. In VS 2022 CE I loaded a uncontrolled solutions then used git to initialise and push the loaded solution. It appears to have created the repository but not pushed the files. It reports there have been errors but doesn't tell me what the errors are. The snapshot below shows the screen - nothing seems to change from first loading a newly installed VS 2022 until after clicking the 'Create Git Repository button'. Clicking 'Add to source Control' or 'Select repository' doesn't seems to change the state of the screen. I have reloaded VS and re-booted & reloaded VS without success. I have tried the solutions suggested in SO without success. one solution suggested typing 'git status' into the Package Manager Console - the PMC said git was not a known command. Screen shot of git in VS.

Do I have to load an extension to get it working?

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
Thepointyman
  • 121
  • 1
  • 7
  • This just happened to me after I updated VS 2022 from 17.1.3 to 17.1.5. The error message I see from the Output panel is "One or more errors occurred." The local repo can be opened in git GUI just fine. No idea what this means. – Feng Jiang Apr 24 '22 at 15:17

4 Answers4

5

I found solution:

  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.

Original post - https://stackoverflow.com/a/71937426/18951991

  • Note: Step 1 done in Windows Explorer. Also prefer this answer to @Zharl because I could only add 1 `safe.directory` project to global git config file, where I have multiple such projects. – HappyGoLucky Jun 23 '22 at 21:36
1

"git config --global --add safe.directory C:/Projects/repo1"

Not sure if same issue, but to me looks like i had the same issue with the git repo not being recognised inside Visual studio.

For me, after clearing VS cache and Clearing Temp files of user and updating git, what fixed the issue was: "git config --global --add safe.directory C:/Projects/repo1". No idea why it would be required though.

Zharl
  • 11
  • 1
1

Open VS as an administrator. Once I did that it worked.

Note, I wasn't able to change the owner to myself because it couldn't see my network identity. Since the owner was administrator I decided to try opening VS as administrator and it worked.

0

It is supposed to have been fixed in the latest release, but I am still experiencing a similar issue (cannot create Git Repository).

My workaround for this is to create the repository in VS 2019. Once the repository is created, everything worked in VS2022. I have to do this for every new project though.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
DongMa
  • 1
  • 1