vscode: VS Code not detecting git repository after update

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.75.0
  • OS Version: Windows 10 Pro (22H2)

Steps to Reproduce:

  1. Open VS Code workspace
  2. Open Source Control tab in Activity Bar

I have been using VS Code to edit this same project for four years. Just today, after updating to 1.75.0, VS Code no longer recognizes my workspace as a valid Git repository, despite it still having a .git folder present.

I disabled all extensions and re-installed VS Code to ensure that my install was not corrupted. I also tried deleting the .git folder in the workspace directory and re-cloning it from my origin repository. The problem persists.

Curiously, it seems to be restricted to this one workspace. I have another workspace that I have been editing with VS Code for the same duration of time and it is not affected. VS Code detects the git repository there just fine.

I am convinced it is not a problem with my Git executable or my repository, as when use git in my terminal or install the extension GitLens (both of which utilize the same git.exe executable as VS Code), neither has any issue interacting with the repository. Only VS Code seems to have this problem.

Here’s the output log for the Git service running on the fresh install with no extensions. It’s not very illuminating. No errors are thrown.

git-output.txt

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 12
  • Comments: 37 (14 by maintainers)

Most upvoted comments

Awesome! Thank you! For the time being please set the setting to always as that will restore the old behaviour. I will further investigate this later today and I will try to get a fix into recovery release that is planned for next week.

Sure I can still see the Commits and Browse them but it wont let me commit new files.

grafik

But setting git.openRepositoryInParentFolders = Always Fixes the problem

@DiamondIceNS, @Attackly could you please share the screenshot of the “Source Control” view? VS Code 1.75 contains some changes related to git repository discovery in parent folders. Are you still able to reproduce the problem if you set the git.openRepositoryInParentFolders to always and reload the window?

@kevin-guertin, thank you very much for the screenshot. I believe I have a repro 🎉 Debugging the issue now…

Thank you, the workaround provided worked perfectly for me.

Just in case it helps; I was only experiencing this issue when I use a workspace. If I open the folder instead of the workspace, it detects the repo. I suspected it might be related to doing a LiveShare- this only happened after the LiveShare ended for me.

Hope that helps, thanks again.

@lszomoru,

Thank you for fixing this.

Verification steps:

  1. Set up the following folder structure, where foo and bar and both folders containing a git repository image
  2. Open the foo workspace using the workspace file in VS Code 1.75 and the “Source Control” view is empty
  3. Open the foo workspace using the workspace file in VS Code 1.75.1 and the “Source Control” view should show the two git repositories

@Jason3S, thank you very much for running all the tests. For the same of clarity let’s keep this issue scoped to the issue of repository discovery. That particular issue has been fix in Insiders and will be included in the Stable recovery release that is planning for later this week. I will file a separate issue to track the problem related to diff decorators.

@Jason3S, could you please confirm that opening the same workspace yields different outcomes when you use VS Code Stable 1.74.3 and VS Code Stable 1.75 and VS Code Insiders 1.76. Just want to narrow down where the problem might be. Thanks!

I checked.

  • 1.74.3 - works just fine.
  • 1.75 VS Code Stable - has issues with git changes not showing.
  • 1.76 Insiders - seem to be working.
Version: 1.76.0-insider
Commit: c9e3ef865539061b5602c6b9ac6030332aa1ce70
Date: 2023-02-06T05:24:10.821Z
Electron: 19.1.9
Chromium: 102.0.5005.194
Node.js: 16.14.2
V8: 10.2.154.23-electron.0
OS: Darwin x64 22.2.0
Sandboxed: Yes

@jomido, thanks for the information. When you opened the “Source Control” view, you should have seen a welcome view similar to the one here. Was that not the case or you just did not switch to the “Source Control” view? The welcome view contains a command to open the git repository from the parent directory.

Apologies for the late response (looks like you’ve got this sorted, anyhow). When I opened VS Code this morning it had updated to 1.75. I don’t think I’ll revert back to 1.74.3 to do a check.

In 1.75 I no longer require the workaround, and the “Source Control” view now appears to be in the correct state, as described above. (I have not used this view on a day-to-day basis, so have nothing to compare it to in an experiential frame of ref.) In addition, when removing the workaround on 1.75, a toast (inline pop up) on the bottom right of the window renders, asking about a git repo discovered one directory above the working directory. This toast was not appearing 2 days prior.

Thanks for the fix!