【问题标题】:how setup heroku toolbelt to use -r <nickname> to specify an app如何设置 heroku toolbelt 以使用 -r <nickname> 指定应用程序
【发布时间】:2014-12-12 03:35:33
【问题描述】:

在我的旧机器上我可以输入

heroku config -r prod

查看昵称为“prod”的应用程序的配置设置(而不是 --app actual_app_name)。

在我的新机器上,使用相同版本的heroku toolbelt,我不记得如何告诉heroku toolbet 接受-r prodn 而不是--app actual_app_name

两台机器上的git config文件好像是一样的,所以不是git confgi设置...

【问题讨论】:

    标签: git heroku


    【解决方案1】:

    2014 年 12 月更新

    andorov 向 Heroku 提及 in the comments 宣布“HTTP Git now Generally Available”:

    现在默认使用 HTTP Git,heroku createheroku git:remoteheroku git:clone 命令都将您的本地环境配置为使用 HTTP Git。
    如果出于任何原因,您想将 SSH Git 与特定应用程序一起使用,只需将 --ssh-git 标志传递给这些命令,例如:

    $ heroku create --ssh-git
    

    如果您想在特定机器上始终使用 SSH Git 和 Heroku,您可以添加以下全局配置:

    git config --global url.ssh://git@heroku.com/.insteadOf https://git.heroku.com/
    

    HTTP URL 仍将被写入 .git 文件夹,但 Git 会即时重写所有 Heroku HTTP Git URL 以使用 SSH。
    请参阅Git documentation 了解详细信息,包括有关如何删除此设置的说明。


    原始答案(2014 年 11 月)

    文章“This Week I Learned #2”提到:

    使用 Heroku 工具带,您可以通过 Git Remote 而不是名称来识别应用程序

    这意味着 -r 后跟远程名称,git remote -v 返回一个。

    所以请检查您的本地远程git remote -v,并尝试使用该名称(引用您的 heroku 应用被推送的远程仓库)。

    看到project example

    创建 Heroku 应用程序仓库并添加 Git 暂存远程,

    heroku login             # if you haven't already
    heroku create --remote staging  # within project dir
    heroku create --remote production
    git remote -v            # expect: origin, staging, production
    

    在这里,项目与两个 Heroku 应用程序相关联,一个用于暂存,另一个用于生产。
    当 git push 时,指定正确的远程,当使用 heroku 命令时,使用 --remote remote-name-r remote-name 选项来指定部署应该去的应用程序。

    要告诉 heroku 命令默认为这个项目暂存,

    git config heroku.remote staging
    

    【讨论】:

    • 这对我来说不适用于 heroku 的新 HTTP git deploy,但您可以使用 git config --global url.ssh://git@heroku.com/.insteadOf https://git.heroku.com/ 默认使用旧 ssh。见这里blog.heroku.com/archives/2014/12/5/…
    • @andorov 好点。我在答案中包含了新 Heroku 政策的更完整摘录,以提高知名度。
    猜你喜欢
    • 2013-07-04
    • 2014-10-13
    • 2012-08-23
    • 1970-01-01
    • 1970-01-01
    • 2013-12-17
    • 2016-04-09
    • 1970-01-01
    • 2012-09-10
    相关资源
    最近更新 更多