我正在 Heroku 上上传一个 php 项目,我正在按照官方网站上给出的说明进行操作。当我到达最后一个命令时
git push heroku master
我收到以下错误:
error: protocol https not supported or disabled in libcurl while accessing https://git.heroku.com/hidden-hamlet-3511.git/info/refs?service=git-receive-pack
fatal: HTTP request failed.
我四处搜索,找不到任何解决方案。
Heroku 部署是通过 git 管理的。Git 有一个称为远程存储库的概念;也就是说,存储在另一台计算机上的存储库。当您git push
时,您将数据发送到这些远程存储库之一。 git push heroku master
的意思是"推送到名为 heroku
的远程存储库上的master
分支"。
您可以使用 git remote
命令查看为存储库配置的远程数据库。例如,如果您运行 git remote -v
,您可能会看到类似这样的内容(您可能还列出了其他内容)。
user@host dir$ git remote -v
heroku https://git.heroku.com/hidden-hamlet-3511.git (push)
heroku https://git.heroku.com/hidden-hamlet-3511.git (fetch)
Git 可以通过两种协议与遥控器一起工作:http 和 ssh。您的遥控器设置为使用 http(Heroku 的默认值),但您的libcurl
库不支持用于 https 的 SSL。这就是您的错误消息的含义 - git 无法使用 https 访问其遥控器。
如果您已为 Heroku 帐户设置 SSH 密钥,则可以删除 https 远程,并将其重新配置为 ssh 远程:
git remote rm heroku
git remote add heroku git@heroku.com:hidden-hamlet-3511.git
您还可以使用 heroku
命令为您添加 ssh 遥控器,删除旧遥控器后:
git remote rm heroku
heroku git:remote -a hidden-hamlet-3511 --ssh-git
Heroku 文档提供了有关将 SSH 与 git remote 一起使用的更多信息。