I'm in the middle of a git bisect
session.
What's the command to find out which commit (SHA-1 hash value) I am currently on? git status
does not provide this.
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
.git status
.git bisect visualize
.I'll explain each option in detail below.
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 use git show
with the -s
option to suppress patch output:
$ git show --oneline -s
a9874fd Merge branch 'epic-feature'
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
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...) $
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
Finally, while you're doing a git bisect
, you can also simply use git bisect visualize
or its built-in alias git bisect view
to launch gitk
, 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