VS Code 中缺少 Git – 没有源代码控制提供程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46609255/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:08:18  来源:igfitidea点击:

Git missing in VS Code – No source control providers

gitvisual-studio-code

提问by ChiliYago

I just installed Visual Studio Code 1.17 and opened a Git repository folder. When entering the Source Control tab I see a message "There are no active source control providers". I thought Git was baked into VSCode!?

我刚刚安装了 Visual Studio Code 1.17 并打开了一个 Git 存储库文件夹。进入“源代码管理”选项卡时,我看到一条消息“没有活动的源代码管理提供程序”。我以为 Git 已经融入了 VSCode!?

To make matters worse, when I attempt to install additional SCM providers there is no option for Git. How do I get my Git back!?

更糟糕的是,当我尝试安装其他 SCM 提供程序时,Git 没有选项。我如何找回我的 Git!?

Visual Studio Code, displaying “No source control providers”

Visual Studio Code,显示“无源代码控制提供程序”

采纳答案by torvin

What helped me is setting the value of git.pathsetting to the full path of my git.exefile. After that I was able to see the git logo:

帮助我的是将设置的值git.path设置为我的git.exe文件的完整路径。之后,我能够看到 git 徽标:

git icon

git 图标

回答by johnwp

Are you using MacOS? If you've updated Xcode lately, you may need to accept Xcode's terms of service agreement to use git.

你在使用 MacOS 吗?如果您最近更新了 Xcode,则可能需要接受 Xcode 的服务条款协议才能使用 git。

$ sudo xcodebuild -license accept

$ sudo xcodebuild -license accept

回答by RodB

I had this too. tried overriding the default git.path setting but that didn't work. What seemed to fix it for me was opening an existing repository .. just an empty folder that I created and did a 'git init' in at the command prompt. After I opened that folder I could click the Source Control button and it had all the git functions available and no longer said "There are no active source control providers". Furthermore, doing File->Close folder got me back to where I started. Another way was to click the small "branch" button ABOVE that message ("There are no active ...") and initialise a repository. This message is very confusing!

我也有这个。尝试覆盖默认的 git.path 设置,但这没有用。似乎对我来说修复它的是打开一个现有的存储库..只是一个我创建的空文件夹,并在命令提示符下执行了“git init”。打开该文件夹后,我可以单击“源代码控制”按钮,它具有所有可用的 git 功能,不再说“没有活动的源代码控制提供程序”。此外,执行 File->Close folder 让我回到了我开始的地方。另一种方法是单击该消息上方的小“分支”按钮(“没有活动...”)并初始化存储库。这个消息非常混乱!

回答by poke

Visual Studio Code doescome with in integrated Git source control provider. However, in order for that to work, Git itself needs to be installed on your system as well. So just download and install Giton your machine, and Visual Studio Code will also be able to use it.

Visual Studio Code确实带有集成的 Git 源代码控制提供程序。然而,为了让它工作,Git 本身也需要安装在你的系统上。所以只要在你的机器上下载并安装 Git,Visual Studio Code 也可以使用它。

While the source control panel does not tell you this, but unfortunately just stays quiet about it, not offering anything, there is a way to have VS Code tell you this: On the “Welcome” page that is displayed when you start the application, there is a link “Clone Git repository…”. If you click there, VS Code will tell you that Git is missing:

虽然源代码控制面板没有告诉你这一点,但不幸的是只是保持沉默,没有提供任何东西,有一种方法让 VS Code 告诉你:在你启动应用程序时显示的“欢迎”页面上,有一个链接“克隆 Git 存储库...”。如果你点击那里,VS Code 会告诉你 Git 丢失了:

It looks like Git is not installed on your system

您的系统上似乎未安装 Git

Once you have installed Git and restarted Visual Studio Code, you will see a small Git icon at the top of the source control panel (unless you already have a repository opened of course):

安装 Git 并重新启动 Visual Studio Code 后,您将在源代码控制面板的顶部看到一个小的 Git 图标(当然除非您已经打开了一个存储库):

Source control panel with a Git icon

带有 Git 图标的源代码控制面板

This will tell you that Git is there and you can click the icon to initialize a repository—or just open an existing repository.

这将告诉您 Git 在那里,您可以单击该图标来初始化存储库 — 或者只是打开现有存储库。

回答by Brian Cragun

For me, the solution was (on Mac) Code > Settings > User Settings > Extensions > Git

对我来说,解决方案是(在 Mac 上)代码 > 设置 > 用户设置 > 扩展 > Git

Check the (unchecked) box next to Enabled - Whether git is enabled.

选中 Enabled - git is enabled 旁边的(未选中)框。

Git enabled setting

启用 Git 的设置

回答by Randel

Simplest steps what worked for me:
1. Download and install Git on your machineas mentioned in Poke's answer.
2. Restart VS Code.
3. Open Command Prompt (Crtl+Shift+P) and write 'Git: Initialize Repository' and choose a folder you like (it can be even a temp folder).
4. Finally Git logo appears as shown in Torvin's answer and then its easy to set up your git account and start using it.

对我有用的最简单步骤:
1.如 Poke 的回答中所述,在您的机器上下载并安装 Git
2. 重新启动 VS 代码。
3. 打开命令提示符 (Crtl+Shift+P) 并写入“Git: Initialize Repository”并选择一个您喜欢的文件夹(它甚至可以是临时文件夹)。
4. 最后,Git 标志出现在 Torvin 的回答中,然后就可以轻松设置您的 git 帐户并开始使用它。

回答by aprinciple

You need initialize (git init in terminal) your project/folder, that your VS Code to be able to see his as git-project.

您需要初始化(终端中的 git init)您的项目/文件夹,您的 VS Code 才能将其视为 git-project。

Enter in your project/folder through terminal

通过终端输入您的项目/文件夹

cd ~/ImbaFolder
git init (it created .git file - the git repository)

Then your VS Code will to see that it is git repository, and it will works.

然后你的 VS Code 会看到它是 git 存储库,它会工作。

回答by Rel

Wow I spent so long on this. For me I had to go to the Extensions area > then click the ... at top right of menu > Show built-in Extensions

哇我花了这么长时间。对我来说,我必须转到扩展区域 > 然后单击菜单右上角的 ... > 显示内置扩展

Git built-in extension was disabled!!

Git 内置扩展被禁用!!

screencapture

截屏

回答by Rahul

If this helps; I did faced the same issue with latest version of VS Code and tried all this mentioned tips but no luck. Finally, I added a folder to a workspace, saved that woerkspace and then when I check the repo icon, could see the small git icon and can as well clone a repo from command palate.

如果这有帮助;我确实在使用最新版本的 VS Code 时遇到了同样的问题,并尝试了所有这些提到的技巧,但没有运气。最后,我向工作区添加了一个文件夹,保存了该工作空间,然后当我检查 repo 图标时,可以看到小的 git 图标,也可以从命令 palate 克隆一个 repo。

Raised an issue for this and commented this same findings. Can be found here https://github.com/Microsoft/vscode/issues/49469

为此提出了一个问题并评论了同样的发现。可以在这里找到https://github.com/Microsoft/vscode/issues/49469

回答by justinbc820

So, I tried all sorts of things to get this to work. I tried "git.path": "/usr/bin/git", adding git directly to my path, etc. Nothing worked.

所以,我尝试了各种方法来让它发挥作用。我试过"git.path": "/usr/bin/git",将 git 直接添加到我的路径等。没有任何效果。

Finally, I realized that in my VSCode workspace settings, I had "git.enabled: false". I changed it to true, and it works like a charm.

最后,我意识到在我的 VSCode 工作区设置中,我有"git.enabled: false". 我把它改成 true,它就像一个魅力。