Specify '–remote' Heroku app based on git branch

Is it possible to to target an app version in Heroku based on the current Git branch? In the Heroku docs, its specifies how to target a a specific version of the app.

# run command on 'production'    
$ heroku run rake db:migrate --remote production

To make things easier, you can use your git config to specify a
default app. For example, if you wanted “staging” do be your default
remote, you could set it with the following command:

  • Pod from github not working
  • Unzip git tree object
  • InteliJ: Force read-only when on master branch
  • PyCharm on a Mac fails to clone a repository: remote end hung up unexpectedly
  • Is there a way to develop a Rational Team Concert (RTC) project in Linux terminal?
  • bundle install doesn't work on with RVM
  • $ git config heroku.remote staging

    It would make sense to have the local development branch push to the development app and the local production branch push to the production app.

  • Using global/system git-review config files (git-review.conf) is deprecated
  • How do I update a GitHub forked repository?
  • is an open port 9418 enough for a GitHub client to fully function?
  • git large pack file, delete and rewrite?
  • git-receive-pack: command not found in Windows
  • How to get 'test' branch into 'master' when 'test' is a branch of 'dev'?
  • One Solution collect form web for “Specify '–remote' Heroku app based on git branch”

    I’m not familiar with Heroku, but you could easily write a shell-script wrapper that would:

    • Get the name of the current branch using git symbolic-ref --short HEAD
    • Get the Heroku target by using git config heroku.<branch>.remote
    • Run the appropriate command

    This assumes that you manually configure a per-branch setting for heroku, e.g.:

    git config heroku.master.remote production
    git config heroku.develop.remote staging
    

    This doesn’t do anything by itself; it’s just lets you read these values in a script using git config.

    Git Baby is a git and github fan, let's start git clone.