如何在heroku CLI中避免--app选项? [英] How to avoid the --app option with heroku CLI?
问题描述
每次在终端中运行heroku
命令时,我都厌倦了输入应用程序名称:
I'm tired of entering the name of my app each time I run a heroku
command in the terminal:
heroku run rake db:migrate --app myapp
heroku run rake db:seed --app myapp
heroku run rake sth:else --app myapp
--app
非常多余且令人讨厌,我不知道在项目中全局一次进行配置的选项.
The --app
is very redundant and annoying, I didn't figured out where were the option to configure it globally once for the project.
推荐答案
heroku
在知道应该与哪个应用程序通信时不需要--app
参数.当只有一个Git远程指向某个存储库的Heroku时,就会发生这种情况.
heroku
doesn't require the --app
argument when it knows which app it should talk to. This occurs when there is exactly one Git remote pointing to Heroku for a repository.
您似乎没有任何指向Heroku的遥控器.运行
You don't appear to have any remotes pointing to Heroku. Run
heroku git:remote --app myapp
添加添加.完成后,您应该可以忽略该特定存储库上heroku
命令的--app
参数.
to add such a remote. Once that's done you should be able to omit the --app
argument for heroku
commands on that particular repository.
如果您愿意自己做,则可以运行
If you prefer to do this yourself you can run
git remote add heroku git@heroku.com:myapp.git
请注意,可能有多个 Heroku遥控器,例如如果您有演出和生产应用程序.在这种情况下,您还必须提供--app
参数来指定应使用哪个参数.
Note that it's possible to have multiple Heroku remotes, e.g. if you have a staging and a production app. In this case you will also have to provide the --app
argument to specify which one should be used.
这篇关于如何在heroku CLI中避免--app选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!