How to avoid the --app option with heroku CLI?

。_饼干妹妹 提交于 2019-12-02 10:06:19

问题


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

The --app is very redundant and annoying, I didn't figured out where were the option to configure it globally once for the project.


回答1:


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.

You don't appear to have any remotes pointing to Heroku. Run

heroku git:remote --app myapp

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

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.



来源:https://stackoverflow.com/questions/55470675/how-to-avoid-the-app-option-with-heroku-cli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!