在VS Code中找不到Git [英] Git not found in VS Code

查看:709
本文介绍了在VS Code中找不到Git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,在Windows 10笔记本电脑上运行的VS Code中找不到Git.在我的Mac的用户默认设置"中,向下滚动时会出现Git,但在Windows 10笔记本电脑中根本不存在.而源代码管理绝对不显示任何内容.知道如何将Git(重新)集成到我的VS代码中吗?

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?

我试图在用户设置列表中包括以下内容,但它一直告诉我"git.path"是一个未知的配置术语:

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配置文件被编码为 JSON . JSON是某些数据结构(在这种情况下为对象)的文本表示形式,并且是JavaScript的子集.对象的键和字符串值必须用双引号(")括起来.

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(与其他许多受C语言启发的语言一样)使用反斜杠字符(\)作为字符串中的转义字符来编码不同的特殊字符,包括引号(\")和反斜杠本身(\\ ).

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 (\\).

由于Windows在路径中使用反斜杠作为目录分隔符,因此您放入VSCode配置文件(或任何其他JSON文件)中的所有路径的反斜杠都必须加倍,以遵循写入字符串的JSON规则.

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.

因此,您的Git路径配置行应类似于:

Accordingly, your Git path configuration line should be like:

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

它可能也可以在没有.exe后缀的情况下使用(在Windows上),但是使用全名而不是依靠魔术来解析不完整的文件名/路径总是更好的选择.

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.

这篇关于在VS Code中找不到Git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆