Search code examples
ruby-on-railsgitheroku

How to determine which commit and/or which branch was deployed to Heroku?


I have an app that is deployed to Heroku, and presume that I haven't done the deployment, how can I check which branch was used to deploy to heroku, or what is the commit ID (as with it I can determine the branch if needed)?

I am using GitHub.

So far I have tried to run in console:

$ heroku releases

and then running the:

$ heroku releases:info v123

But it didn't show anything.

How can I determine the commit or branch name from the deployed app on heroku?

It is a Rails app (maybe it might help to determine this information)


Solution

  • The "releases" feature does not help you because it's an internal counter Heroku is using to keep track of pushes and re-configuration.

    If you re-configure your app, the counter will increase. Deployments will also increase the counter but that doesn't help you.

    But remember that Heroku is just another "git remote." So if you are on the machine which you used to deploy, there must be this:

    $ git remote show heroku
    * remote heroku
      Fetch URL: https://git.heroku.com/your-app-3367.git
      Push  URL: https://git.heroku.com/your-app-3367.git
      HEAD branch: master
      Remote branch:
        master tracked
      Local ref configured for 'git push':
        master pushes to master (up to date)
    

    If you have a similar output, you can just:

    git show heroku/master
    

    and see the commit that was pushed and deployed most recently.