How to view remote Git revision on Heroku

GitHerokuGit Remote

Git Problem Overview


For deploying to Heroku, I use git push heroku master. But how do I see which revision I pushed up to heroku? (I'm often in doubt if I pushed the recent version up)

For those not familiar with it, Heroku's create script generates a remote git repository that you push to. Upon push, the code is deployed magically.

Heroku adds a remote repository to the local one in the form:

$ git remote add heroku git@heroku.com:appname.git

More info in Heroku's manual "Deploying with Git"

Question is: How can I see latest version in Heroku repository?

Git Solutions


Solution 1 - Git

The correct answer is actually so simple. You don't need to checkout anything, neither do you have to resort to COMMIT_HASH hacks (which don't work on Cedar stack). All you need to do is: git ls-remote <remote>

 > git ls-remote heroku
ddaszxcewb585d3a3c00de816a197b14462791a3        HEAD
ddaszxcewb585d3a3c00de816a197b14462791a3        refs/heads/master

Solution 2 - Git

If you've just pushed and want to make sure you're up-to-date, then you can just run git remote show heroku and you'll see output similar to this:

* remote heroku
  Fetch URL: git@heroku.com:XXX.git
  Push  URL: git@heroku.com:XXX.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local ref configured for 'git push':
    master pushes to master (up to date)

That (up to date) at the end will be replaced by (fast forwardable) if it is not up to date.

Or, if you're wanting to see the full commit log for the heroku remote, the only way I know how is to check it out first. git checkout heroku/master will give you the current commit hash and commit comment: HEAD is now at <short commit hash>... <commit comment>, and git log will give you the rest of the story.

Solution 3 - Git

You may now want heroku releases and you'll see like 5 commits. a start at least.

Solution 4 - Git

what about

git log heroku/master

Solution 5 - Git

if you've run into the situation, like i just did, where a co-worker rolled back your heroku app to a release that doesn't show in heroku releases because they only keep track of 2 releases... the checkout of heroku/master method won't help, because HEAD is not what is deployed anymore.

the undocumented to the rescue:

$ heroku console "ENV['COMMIT_HASH']"
"12abcdef"

Solution 6 - Git

heroku is using plain old Git underneath, so..

show the latest 5 commits on current branch: git log -5

show commit history via Git's gui: gitk

view current status (it'll show if you have any uncommited files): git status

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJesper R&#248;nn-JensenView Question on Stackoverflow
Solution 1 - GitdolzenkoView Answer on Stackoverflow
Solution 2 - GitBrock BatsellView Answer on Stackoverflow
Solution 3 - GitpjammerView Answer on Stackoverflow
Solution 4 - GitewebView Answer on Stackoverflow
Solution 5 - GitkenichiView Answer on Stackoverflow
Solution 6 - Gitmj101View Answer on Stackoverflow