git 在 VSCode 中克隆 GitHub 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38307647/
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 04:21:36  来源:igfitidea点击:

Clone GitHub repository in VSCode

gitvisual-studio-code

提问by Paul B

I'm trying to clone a GitHub repository into the newest release of VSCode (1.3.0). Can this be done natively or do I need to add an extension or additional binary?

我正在尝试将 GitHub 存储库克隆到最新版本的 VSCode (1.3.0) 中。这可以在本地完成还是我需要添加扩展或额外的二进制文件?

I've also searched for a blog article and coming up empty handed so any guidance would be appreciated

我还搜索了一篇博客文章,结果空手而归,所以任何指导都将不胜感激

Paul

保罗

回答by Jakub Synowiec

Starting from the 1.8 (November) update of vscode you can now clone your Git repository from within the vscode.

从 vscode 的 1.8(11 月)更新开始,您现在可以从 vscode 中克隆您的 Git 存储库。

You can execute it from the Command Palette. Press F1(or ?+?+Pon Mac) and search for Git: Clone. Confirm the command and paste the repository url.

您可以从命令面板执行它。按F1(或?+ ?+P在Mac)和搜索Git: Clone。确认命令并粘贴存储库 URL。

回答by Slowmove

If you by native means in the GUI of the application, the answer is no. Though there is an open issue regarding this on their Github repository https://github.com/Microsoft/vscode/issues/9085it doesn't look like they have the interest to implement it.

如果您在应用程序的 GUI 中通过本机方式,答案是否定的。尽管在他们的 Github 存储库https://github.com/Microsoft/vscode/issues/9085上有一个关于此的未决问题,但看起来他们没有兴趣实施它。

Even so, you can of course still clone a repository in your Terminal of choice and then handle the rest of your git functionality through the editor when you're working with the project.

即便如此,您当然仍然可以在您选择的终端中克隆一个存储库,然后在您处理项目时通过编辑器处理其余的 git 功能。

回答by Jan Dolejsi

There are now two programmatic ways how to clone a repository. VS Code handles the vscode://protocol now, so you could clone a repository by clicking on a link somewhere on a web page

现在有两种编程方式来克隆存储库。VS Codevscode://现在处理协议,因此您可以通过单击网页上某处的链接来克隆存储库

For example, clicking on the following link invokes VS Code, lets you select a folder on your disk, fetches the code and finally suggests to open that location as a workspace.

例如,单击以下链接会调用 VS Code,让您选择磁盘上的文件夹,获取代码,最后建议将该位置作为工作区打开。

vscode://vscode.git/clone?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fvscode-extension-samples

vscode://vscode.git/clone?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fvscode-extension-samples

Alternatively, if you are trying to trigger the cloning from an extension code, use the built-in VS Code command git.clonewith the repo url as the only argument.

或者,如果您尝试从扩展代码触发克隆,请使用内置 VS Code 命令git.clone,并将 repo url 作为唯一参数。

import { commands} from 'vscode';

commands.executeCommand("git.clone", "https://github.com/microsoft/vscode-extension-samples");

Both seem to do the same as the Git: Clonecommand mentioned by Jakub.

两者似乎都与Jakub 提到的Git: Clone命令相同。

回答by powershellcrack

I use github Desktop (https://desktop.github.com/) for both my github repos and gitlab repos

我将 github 桌面(https://desktop.github.com/)用于我的 github 存储库和 gitlab 存储库