Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在vscode中使用ssh克隆私有git repo?_Git_Github_Ssh_Visual Studio Code - Fatal编程技术网

如何在vscode中使用ssh克隆私有git repo?

如何在vscode中使用ssh克隆私有git repo?,git,github,ssh,visual-studio-code,Git,Github,Ssh,Visual Studio Code,我正在使用mac,我想知道如何使用vscode通过ssh克隆私有github repo?我查看了code.visualstudio.com/docs/editor/versioncontrol,但找不到任何关于使用ssh进行克隆的信息 在vscode中,我转到左侧的源代码管理图标,然后单击克隆存储库。我输入git@github.com:username/project并显示权限被拒绝。我确实生成了公钥和私钥,但在哪里输入它们呢?Ssh是您在Ssh代理中设置的,它与bash一起工作。我已经使用Vs

我正在使用mac,我想知道如何使用vscode通过ssh克隆私有github repo?我查看了code.visualstudio.com/docs/editor/versioncontrol,但找不到任何关于使用ssh进行克隆的信息


在vscode中,我转到左侧的源代码管理图标,然后单击克隆存储库。我输入
git@github.com:username/project
并显示权限被拒绝。我确实生成了公钥和私钥,但在哪里输入它们呢?

Ssh是您在Ssh代理中设置的,它与bash一起工作。我已经使用Vscode很长一段时间了,我总是使用GitBash设置ssh,这更简单。我使用git bash将一个项目克隆到我的工作区中,然后使用vscode打开它

就我所见,您无法从vscode设置ssh


如果您希望从终端安装ssh,文档是。

ssh是您在ssh代理中设置的东西,它与bash一起工作。我已经使用Vscode很长一段时间了,我总是使用GitBash设置ssh,这更简单。我使用git bash将一个项目克隆到我的工作区中,然后使用vscode打开它

就我所见,您无法从vscode设置ssh


如果您希望从终端安装ssh,那么文档是。

我今天刚刚讨论了这个问题。我假设您已经安装了Git for Windows,并在用户的“.ssh”文件夹中生成了ssh密钥。 之后,您必须联机转到GitHub帐户中的设置,并在左侧菜单中查找“SSH和GPG密钥”选项:

在这里,您必须输入公钥,方法是打开“id\u rsa.pub”文件,然后单击“新建SSH密钥”将其内容复制到GitHub帐户中:

然后,您可以像使用常规HTTP连接一样使用vscode。只需Crtl+Shift+P打开vscode的命令托盘,选择git:clone,粘贴所需GitHub repo的SSH地址。为了在单击GitHub repo上的绿色“克隆或下载”按钮时获取SSH地址,还必须在弹出的框中单击“克隆SSH”,以便复制SSH地址,而不是使用HTTPS链接

您可能遇到的唯一问题是,第一次在vscode中尝试ssh时,它会说,“无法识别主机”。解决此问题的方法是从vscode外部的git bash命令行执行git克隆,这样当它询问您是否可以添加GitHub的ssh密钥指纹时,您可以键入“yes”

ROB@WINDOW10 MINGW64 ~/Documents
$ git clone git@github.com:Rob4226/example.git
Cloning into 'Example Repo'...
The authenticity of host 'github.com (140.82.114.3)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? **yes**
Warning: Permanently added 'github.com,140.82.114.3' (RSA) to the list of known hosts.
无论出于何种原因,vscode git源代码管理UI都不会显示此消息供您响应,因此它只会抛出一个错误。但是,在您第一次在gitbash命令行中说“是”之后,ssh将从现在起在vscode中工作,不会出现任何问题。它工作得很好,而且速度快得多!我不再使用vscode中的HTTPS

或者,您可以手动将GitHub的SSH密钥指纹添加到.SSH文件夹中的“已知\u主机”文件中。它们可以在这里找到:


我今天刚刚经历了这些。我假设您已经安装了Git for Windows,并在用户的“.ssh”文件夹中生成了ssh密钥。 之后,您必须联机转到GitHub帐户中的设置,并在左侧菜单中查找“SSH和GPG密钥”选项:

在这里,您必须输入公钥,方法是打开“id\u rsa.pub”文件,然后单击“新建SSH密钥”将其内容复制到GitHub帐户中:

然后,您可以像使用常规HTTP连接一样使用vscode。只需Crtl+Shift+P打开vscode的命令托盘,选择git:clone,粘贴所需GitHub repo的SSH地址。为了在单击GitHub repo上的绿色“克隆或下载”按钮时获取SSH地址,还必须在弹出的框中单击“克隆SSH”,以便复制SSH地址,而不是使用HTTPS链接

您可能遇到的唯一问题是,第一次在vscode中尝试ssh时,它会说,“无法识别主机”。解决此问题的方法是从vscode外部的git bash命令行执行git克隆,这样当它询问您是否可以添加GitHub的ssh密钥指纹时,您可以键入“yes”

ROB@WINDOW10 MINGW64 ~/Documents
$ git clone git@github.com:Rob4226/example.git
Cloning into 'Example Repo'...
The authenticity of host 'github.com (140.82.114.3)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? **yes**
Warning: Permanently added 'github.com,140.82.114.3' (RSA) to the list of known hosts.
无论出于何种原因,vscode git源代码管理UI都不会显示此消息供您响应,因此它只会抛出一个错误。但是,在您第一次在gitbash命令行中说“是”之后,ssh将从现在起在vscode中工作,不会出现任何问题。它工作得很好,而且速度快得多!我不再使用vscode中的HTTPS

或者,您可以手动将GitHub的SSH密钥指纹添加到.SSH文件夹中的“已知\u主机”文件中。它们可以在这里找到:

这本指南是最好的这本指南是最好的