STUDY MEMO

学習のメモ書き

< Heroku > herokuのステージング環境とプロダクション環境のCLIの紐付け

以下のコマンドでstagingをデフォルトのherokuリモートにする。

$ git config heroku.remote staging

.git/configファイルに以下が追記される。

[heroku]
  remote = staging

この記載がされることで、CLIコマンドがデフォルトでstagingアプリを管理するようになる。

以下のようにremoteを追加されていれば、

$ heroku git:remote -a アプリ名(staging)
$ heroku git:remote -r production -a アプリ名(production)

.git/configファイルは以下のようになる。

[heroku]
    remote = staging
[remote "staging"]
    url = https://git.heroku.com/アプリ名-staging.git
    fetch = +refs/heads/*:refs/remotes/staging/*
[remote "production"]
    url = https://git.heroku.com/アプリ名.git
    fetch = +refs/heads/*:refs/remotes/production/*

上記という前提があると、以下のコマンドを実行することで、productionアプリに対して実行ができる。

$ heroku logs -t -r production

参考文献

アプリの複数の環境の管理 | Heroku Dev Center