我对 git 还很陌生,除了 Windows 之外很少使用任何东西进行编程。
我已经使用 create-react-app
设置了一个 React 应用程序, 并使用了 gh-pages
将其部署到我的 github.io 项目页面。我已经在我的本地机器上设置了一个 SSH key 并将其添加到我的 github SSH key 中。运行ssh-agent
和 ssh-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/