gitvisual-studio-code

Why vscode don't recognize my .git folder?


Please help me, my VSCode and git were working perfectly but all of a sudden, it stopped recognizing my .git folder.

I open the VSCode terminal in the same path my .git is, but it did not recognize the git, and cannot send any git command.

When I created an empty folder and clone my repo, it worked perfectly BUT ONLY FOR 1 MINUTE.

It cloned, it showed the files in the root explorer of the VSCode BUT then it magically vanishes and I didn't do a single thing, in VSCode second image you can see that it says "the folder currently open doesn't have a git repo" but THAT'S A LIE, 1 minute earlier, it showed me my repo and let me do commits (well, I didn't do any of them because it vanished so quickly)

Please, help me, I don't know what to do, I'm using VSCode "STABLE" BUILD, Git downloaded from https://git-scm.com/.

Even when I open git bash in my folder, git is not recognized!! How is that possible? It worked a minute ago in the VSCode terminal!!

vscode pic

vscode pic 2

root

.git root folder

git bash


Solution

  • Double-check your Windows 10 Defender setting. The latest W10 21H1 edition comes with a ransomware protection which can prevent processes to access certain folders and/or quarantine files/folders.

    And make sure to not create a repository in a synchronized folder like OneDrive: The Git repository state will get desynchronized at some point for sure.

    To test both those possible causes, try and create or clone a local repository in a file outside %USERPROFILE%/OneDrive, with a simple path like C:\myNewRepo.
    See if a VSCode still has the same issues then.