简体   繁体   中英

Git not found in VS Code

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"

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM