git - 为不在 Git Bash 中的 git 配置 SSH key

标签 git github ssh npm sublimetext3

我对 git 还很陌生,除了 Windows 之外很少使用任何东西进行编程。

我已经使用 create-react-app 设置了一个 React 应用程序, 并使用了 gh-pages 将其部署到我的 github.io 项目页面。我已经在我的本地机器上设置了一个 SSH key 并将其添加到我的 github SSH key 中。运行ssh-agentssh-add使在 Git Bash 中的部署变得简单,无需输入用户名和密码。伟大的。

但是,我正在使用 Sublime Text为了我的开发,想用 npm plugin运行 npm run deploy直接从编辑器。我收到以下错误:

Cloning git@github.com:<username>/<repo>.git into node_modules\gh-pages\.cache
Cloning into 'node_modules\gh-pages\.cache'...
Permission denied (publickey).

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

除非我猜错了,否则 git 似乎不知道自动使用 SSH key ,无论它是从哪里运行的。有没有办法配置这个?

最佳答案

确保在您的环境变量中定义:

  • 一个 PATH其中包括 <git>/bin以及 <git>/usr/bin (带有 <git>latest Git For Windows 的安装路径)
    ( usr/bin 确实包括 ssh.exe );
  • 一个 HOME环境变量设置为您的 %USERPROFILE%

  • 确保您在 dir %HOME%\.ssh 中看到您的公钥/私钥

    然后从该 session 启动 SublimeText。

    关于git - 为不在 Git Bash 中的 git 配置 SSH key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42407820/

    相关文章:

    git - 各个 git 存储库中的 Terraform Kubernetes 服务定义?

    java - ssh 套接字工厂

    git - 我怎样才能将一些文件忽略到与 github 同步的本地存储库中?

    ruby - 如何使用 octokit 列出我自己的 github 存储库

    c# - 在 C# 中如何使用 TcpClient 在远程 SSH 上运行 unix 命令

    bash - 使用 SSH key 验证 SSH 连接

    Intellij 中的 Git rebase - 如何一键选择所有临时提交为 "squash"?

    git - 'delete mode 100644' 在 git 提交中意味着什么?

    Git Discipline : combining multiple feature branches, 但仍将它们分开?

    git - 使用访问 token 推送到 github 的最小范围集