如何在 Heroku 上查看远程 Git 修订

对于部署到 Heroku,我使用的是 ABc0。但是我怎么才能知道我把哪个版本推到了 heroku 呢?(我经常怀疑我是否把最近的版本推高了)

对于那些不熟悉它的人,Heroku 的 create 脚本生成一个远程 git 存储库,您可以将其推送到该存储库。在推送时,代码被神奇地部署。

Heroku 以下面的形式向本地存储库添加了一个远程存储库:

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

更多信息见 Heroku 手册

问题是: 如何在 Heroku 知识库中查看最新版本?

66524 次浏览

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.

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"

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

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

what about

git log heroku/master

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