1

Here below are outputs I got when I opened my vscode, and vscode source control does not work any more after that.

Tried to reinstall Git or vscode for many times but no help. But I have no idea how vscode runs Git inside.

Looking for git in: C:\Program Files\Git\cmd\git.exe
Using git  from C:\Program Files\Git\cmd\git.exe
> git rev-parse --git-dir
fatal: not a git repository (or any of the parent directories): .git
> git rev-parse --git-dir
fatal: not a git repository (or any of the parent directories): .git
> git rev-parse --git-dir
fatal: not a git repository (or any of the parent directories): .git
> git rev-parse --git-dir
fatal: not a git repository (or any of the parent directories): .git
> git rev-parse --git-dir
fatal: not a git repository (or any of the parent directories): .git
> git rev-parse --git-dir
fatal: not a git repository (or any of the parent directories): .git
> git rev-parse --git-dir
fatal: not a git repository (or any of the parent directories): .git
halfer
  • 19,824
  • 17
  • 99
  • 186
Prisoner
  • 21
  • 3

1 Answers1

0

Try and open VSCode from command line, in the root folder of your repository:

cd c:\path\to\repo
"%LOCALAPPDATA%\Programs\Microsoft VS Code\bin\code.cmd" -n .

See if the error message persists then.

Do not open it in c:\path\to\repo\.git.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank you for your answering VonC, I tried your command just now but the error messages remain the same. It seems like to me that vscode tries to connect its source control stuff somewhere else (not the dir where my repo lies in). – Prisoner Nov 19 '20 at 07:56
  • @Prisoner Did you use a final '.' in the command I mention? To force it to open on that folder? – VonC Nov 19 '20 at 08:03
  • @Prisoner See also https://github.com/DonJayamanne/gitHistoryVSCode/issues/233#issuecomment-375769718: on Windows, in a CMD, type `set GIT_DIR`, and check if it returns a non-empty value. If yes, make sure to unset GIT_DIR. – VonC Nov 19 '20 at 08:04
  • @Prisoner Check also what kind of plugin you have installed. Do you have gitHistoryVSCode? – VonC Nov 19 '20 at 08:05
  • Yep I did type that '.' in the end. After typing `set GIT_DIR`, I get an empty value. Just checked , i do not have gitHistoryVSCode plugin or any other git plugin installed. – Prisoner Nov 19 '20 at 08:12
  • @Prisoner OK, and I suppose your Git for Widows is the latest Git 2.29.2? – VonC Nov 19 '20 at 08:13
  • `git --verison` shows `git version 2.29.2.windows.2`, should i install an older version of git instead? – Prisoner Nov 19 '20 at 08:17
  • @Prisoner Was it working at anytime before? What settings do you have in VSCode regarding git? – VonC Nov 19 '20 at 08:20
  • `"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe", "terminal.integrated.shellArgs.windows": [ "-l" ]` Yeah that source control thing works until this Tuesday. – Prisoner Nov 19 '20 at 08:29
  • @Prisoner Do you have the setting `git.path` set? – VonC Nov 19 '20 at 08:39
  • @Prisoner Can you try and launch vscode as mentioned in the answer, but in a CMD with a simplified PATH? (as in https://stackoverflow.com/a/63835684/6309) – VonC Nov 19 '20 at 08:40
  • no I cannot launch vscode in a CMD with a simplified PATH, I got `bash: fg: %LOCALAPPDATA%\Programs\Microsoft VS Code\bin\code.cmd: no such job` – Prisoner Nov 19 '20 at 09:50
  • @Prisoner bash? Are you in a git bash session? Or in a regular CMD? – VonC Nov 19 '20 at 09:52
  • I was in bash, just tried regular CMD too, vscode opened, the same error message pops up.. – Prisoner Nov 19 '20 at 10:22
  • @Prisoner Yes, forget bash: everything I mention is in the context of a regular CMD. Did you set a simplified PATH in the CMD before launching VSCode? – VonC Nov 19 '20 at 10:23
  • Yes sir, I did set `%LOCALAPPDATA%` before entering the cmd in a cmd, vscode opened up but the error message is still there :( – Prisoner Nov 20 '20 at 00:41
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/224829/discussion-between-vonc-and-prisoner). – VonC Nov 20 '20 at 07:18