如何在 Heroku 上查看远程 Git 修订版
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2281772/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to view remote Git revision on Heroku
提问by Jesper R?nn-Jensen
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)
为了部署到 Heroku,我使用git push heroku master
. 但是我如何查看我推送到 heroku 的哪个版本?(我经常怀疑我是否将最新版本推高了)
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 的创建脚本会生成一个您推送到的远程 git 存储库。推送后,代码会神奇地部署。
Heroku adds a remote repository to the local one in the form:
Heroku 将远程存储库以以下形式添加到本地存储库:
$ git remote add heroku [email protected]:appname.git
More info in Heroku's manual "Deploying with Git"
Heroku 手册“使用 Git 部署”中的更多信息
Question is: How can I see latest version in Heroku repository?
问题是:如何在 Heroku 存储库中查看最新版本?
采纳答案by Brock Batsell
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:
如果你刚刚推送并想确保你是最新的,那么你可以运行git remote show heroku
,你会看到类似这样的输出:
* remote heroku
Fetch URL: [email protected]:XXX.git
Push URL: [email protected]: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.
这(up to date)
在年底将被替换(fast forwardable)
,如果它不是最新的。
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.
或者,如果您想查看 heroku 遥控器的完整提交日志,我知道的唯一方法是先查看它。 git checkout heroku/master
将为您提供当前的提交哈希和提交评论:HEAD is now at <short commit hash>... <commit comment>
,git log
并将为您提供故事的其余部分。
回答by dolzenko
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>
正确答案其实就是这么简单。您不需要检查任何东西,也不需要求助于 COMMIT_HASH hacks(这不适用于 Cedar 堆栈)。您需要做的就是:git ls-remote <remote>
> git ls-remote heroku
ddaszxcewb585d3a3c00de816a197b14462791a3 HEAD
ddaszxcewb585d3a3c00de816a197b14462791a3 refs/heads/master
回答by pjammer
You may now want heroku releases
and you'll see like 5 commits. a start at least.
你现在可能想要heroku releases
,你会看到 5 次提交。至少一个开始。
回答by eweb
what about
关于什么
git log heroku/master
回答by kenichi
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.
如果你遇到了这种情况,就像我刚刚做的那样,一位同事将你的 heroku 应用程序回滚到一个没有显示的版本,heroku releases
因为他们只跟踪 2 个版本...... heroku/master 结帐方法无济于事,因为 HEAD 不再是部署的东西。
the undocumented to the rescue:
无证救援:
$ heroku console "ENV['COMMIT_HASH']"
"12abcdef"
回答by mj101
heroku is using plain old Git underneath, so..
heroku 在下面使用普通的旧 Git,所以..
show the latest 5 commits on current branch:
git log -5
显示当前分支上的最新 5 次提交:
git log -5
show commit history via Git's gui:
gitk
通过 Git 的 gui 显示提交历史:
gitk
view current status (it'll show if you have any uncommited files):
git status
查看当前状态(它会显示您是否有任何未提交的文件):
git status