Is there a way to set a default app for Heroku Toolbelt?
Asked Answered
B

3

46

I have more than one app/git remote at heroku and I would like to know if it is possible to configure a default application so that, whenever I forget to specify the app (--app), the toolbelt would use it.

Backspin answered 5/7, 2013 at 23:9 Comment(0)
H
50

You can set the heroku.remote key in your repo's Git config to the name of the default remote. For example, if your remote is called staging, you could do this:

$ git config heroku.remote staging

To see how this works, here is the relevant source.

For more, information about this, see Managing Multiple Environments for an App.

Heavyarmed answered 9/7, 2013 at 5:9 Comment(6)
Answer with source, nice! If I could double vote, I would do it.Backspin
Am I misunderstanding what this should do? I was expecting this to allow me to use heroku toolbelt CLI without having to specify --app. It's not working for me:Halting
@Halting Would you mind to paste git remote -v results?Backspin
this is an awesome solutionHodgkin
The current Heroku CLI seems to set git remote name heroku as default (ref. devcenter.heroku.com/articles/git#for-a-new-heroku-app). So many users should set heroku instead of staging (i.e. $ git config heroku.remote heroku). The remote name can be checked by $ git remote -v. If the output is like this: git-remote-name https://git.heroku.com/your-heroku-app-name.git, you should type $ git config heroku.remote git-remote-name.Allier
@Halting I was having the same issue, and fixed it by running git config heroku.remote heroku and then heroku git:remote -a <app-name>Fresher
V
44

You could also go for:

heroku git:remote -a <name-of-the-app>

or if you tend to make a lot of mistakes in the configuration of wrong apps, you can use this library I made: https://github.com/kubek2k/heroshell

This is a Heroku wrapper shell that allows you to work in the context of a given Heroku application

Vlf answered 4/8, 2017 at 11:44 Comment(1)
This is the answer that actually sets the default Heroku app, so you don't have to keep specifying '-a'Jaynes
T
33

You can set the HEROKU_APP environment variable.

Found this question while searching for it myself. The other answers refer to Heroku's old ruby-based CLI. The new JS CLI doesn't seem to support the same git-remote-reading feature. A quick search of the source code on GitHub found this.

Thibodeaux answered 15/4, 2020 at 1:8 Comment(1)
This worked for me to set the default app for Heroku CLI in order to avoid specifying the -a or --app parameter in all commands.Ketti

© 2022 - 2024 — McMap. All rights reserved.