首页 文章

使用相同的代码和git存储库部署2个不同的heroku应用程序

提问于
浏览
17

我正在尝试使用相同的git存储库创建2个不同的Heroku应用程序 using the same code . App1是由我的朋友在Heroku中创建的,并且我试图部署 . 这可能吗?

当我尝试将第二个应用程序部署到Heroku时,我收到错误:

$ git push heroku branch1:master    
!  my_email_id@gmail.com not authorized to access app1
fatal: The remote end hung up unexpectedly

2 回答

  • 7

    Heroku开发中心有一个非常好的指南:https://devcenter.heroku.com/articles/multiple-environments

  • 26

    您需要为Heroku的每个应用程序设置不同的git远程 endpoints ,以便您可以从一个本地存储库推送到任一应用程序 . 我不使用'heroku'名称作为我的遥控器(不是真的很重要)我使用 生产环境 和临时映射到不同的Heroku应用程序 . 所以我可以这样做:

    git push production master
    

    要么

    git push staging staging:master
    

    通过项目根目录中的 git remote -v 检查远程 endpoints . 它将显示映射到您的应用程序的默认heroku .

    通过仪表板在Heroku上获取应用程序的URL,然后执行

    git remote add production <gitrepo for production app here>
    
    git remote add staging <gitrepo for staging app here>
    

    但是,从您发布的错误看起来您似乎不是app1应用程序的协作者 .

相关问题