在Git中查找当前签出的提交 [英] Find which commit is currently checked out in Git
问题描述
我处于 git bisect
会话中间。
找到我目前正在进行的提交(SHA1哈希)是什么命令? git status
不提供此功能。
编辑:我想调用 git log
并查看第一个输入的作品?
您至少有5种不同的方式来查看您当前在工作副本中签出的提交$ c> git bisect 会话(请注意,选项1-4也可以在没有对分时使用)
-
git show
。 -
git log -1
。 - Bash提示符。
-
git status
$下面将详细解释每个选项。
选项1:git show
正如这个答案对于如何确定您当前已经签出哪个提交的常见问题(不只是在
git bisect
中),你可以用git show
和-s
选项禁止输出补丁:$ git show --oneline -s
a9874fd合并分支'史诗功能'
选项2:git log -1
您也可以简单地执行
git log -1
来找出您当前正在进行的提交。$ git log -1 --oneline
c1abcde添加功能-003
选项3:Bash提示符
在Git 1.8.3+版本中(或者是早期版本?你的Bash提示配置为显示你已经签出的当前分支r工作副本,那么它也会向您显示您在平分会话期间或处于分离的HEAD状态时签出的当前提交。在下面的示例中,我目前已检出
c1abcde
:
#提示在分离的
用户〜(c1abcde ...)| BISECTING
#在分离的HEAD状态提示
用户〜(c1abcde ...)$
选项4:git status
运行
git status
也会显示你在对分期间和分离期间检出了什么提交HEAD状态:
$ git status
#HEAD在c1abcde处分离<==右边
选项5:git bisect visualize
最后,重做一个
git bisect
,你也可以简单地使用git bisect visualize
或其内置别名git bisect视图
来启动
gitk
,以便您可以以图形方式查看您正在进行的提交,以及迄今为止哪些提交已标记为不良并且很好。我很确定这个版本在1.8.3版本之前就已经存在了,我只是不确定它是在哪个版本中引入的:git bisect visualize
git bisect view#short,意思是同样的事情
I'm in the middle of a
git bisect
session.What's the command to find out which commit (SHA1 hash) I am currently on?
git status
does not provide this.Edit: I guess calling
git log
and looking at first entry works?解决方案You have at least 5 different ways to view the commit you currently have checked out into your working copy during a
git bisect
session (note that options 1-4 will also work when you're not doing a bisect):git show
.git log -1
.- Bash prompt.
git status
.git bisect visualize
.
I'll explain each option in detail below.
Option 1: git show
As explained in this answer to the general question of how to determine which commit you currently have checked-out (not just during
git bisect
), you can usegit show
with the-s
option to suppress patch output:$ git show --oneline -s a9874fd Merge branch 'epic-feature'
Option 2: git log -1
You can also simply do
git log -1
to find out which commit you're currently on.$ git log -1 --oneline c1abcde Add feature-003
Option 3: Bash prompt
In Git version 1.8.3+ (or was it an earlier version?), if you have your Bash prompt configured to show the current branch you have checked out into your working copy, then it will also show you the current commit you have checked out during a bisect session or when you're in a "detached HEAD" state. In the example below, I currently have
c1abcde
checked out:# Prompt during a bisect user ~ (c1abcde...)|BISECTING $ # Prompt at detached HEAD state user ~ (c1abcde...) $
Option 4: git status
Also as of Git version 1.8.3+ (and possibly earlier, again not sure), running
git status
will also show you what commit you have checked out during a bisect and when you're in detached HEAD state:$ git status # HEAD detached at c1abcde <== RIGHT HERE
Option 5: git bisect visualize
Finally, while you're doing a
git bisect
, you can also simply usegit bisect visualize
or its built-in aliasgit bisect view
to launchgitk
, so that you can graphically view which commit you are on, as well as which commits you have marked as bad and good so far. I'm pretty sure this existed well before version 1.8.3, I'm just not sure in which version it was introduced:git bisect visualize git bisect view # shorter, means same thing
这篇关于在Git中查找当前签出的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!