2

Git is for some reason not found in my VS Code running on a Windows 10 laptop. On my mac in 'User default settings' there is a Git when you scroll all the way down, but in my Windows 10 laptop it doesn't exist at all. and the Source Control shows absolutely nothing. Any idea how I can (re-)integrate Git into my VS Code?

I tried to include the following in my user settings list but it keeps telling me that "git.path" is an unknown configuration term:

"git.path" : "C:\\Program Files\\Git\\cmd"
Gama11
  • 31,714
  • 9
  • 78
  • 100
hamada-insilico
  • 71
  • 1
  • 1
  • 5
  • A similar question was asked here https://stackoverflow.com/questions/51581933/vs-code-there-are-no-active-source-control-providers-linux As snugghash said. Try `git init && code .` (equivalent on windows). Find the `git --version` and the `PATH` of git.exe – clamentjohn Jul 29 '18 at 18:43
  • Thanks for the prompt reply. I tried all that but still no luck. As for the PATH, I cannot do anything with it because it flags "git.path" as error with squiggly red line... – hamada-insilico Jul 29 '18 at 18:54

2 Answers2

5

VSCode configuration files are encoded as JSON. JSON is a text representation of some data structure (objects in this case) and it is a subset of JavaScript. The keys of the object and the string values must be enclosed in double quotes (").

JavaScript (as many other languages inspired from C) use the backlash character (\) as an escapte character in strings to encode different special characters, including the quotes (\") and the backslash itself (\\).

Because Windows uses backlash as the directory delimiter in paths, all paths you put in VSCode configuration files (or in any other JSON file) must have their backslashes doubled to follow the JSON rules of writing strings.

Accordingly, your Git path configuration line should be like:

"git.path" : "C:\\Program Files\\Git\\cmd.exe"

It probably works also without the .exe suffix (on Windows) but it's always better to use the entire name and not rely on magic to resolve incomplete file names/paths.

axiac
  • 68,258
  • 9
  • 99
  • 134
  • Could you please post your answer for [this](https://stackoverflow.com/questions/51581933/vs-code-there-are-no-active-source-control-providers-linux) as well? I did stumble upon the git.path thing, but you answered before me. Edit: That makes zero sense, I'm doing it myself. Sorry for bothering you haha. – snugghash Aug 06 '18 at 16:45
  • Much better to just use forward slashes (which Windows supports for ages); copying from my config: `"git.path" : "S:/git/current/bin/git.exe"`. – Sz. Oct 23 '18 at 17:47
5

It looks like the built-in Git extension was disabled for some reason. To activate it you have to go to Extensions and then type @builtin Git and then enable it.

hamada-insilico
  • 71
  • 1
  • 1
  • 5