I am aware that it is possible to fix a git bisect
session via git bisect log
and git bisect replay
as described in the answers to this question.
However, when I mess up a bisect session, that's likely just a single wrong decision, and I would like to be able to fix it directly (i.e. without aborting the whole thing).
For instance, I can imagine that it should be possible to just do rm .git/refs/bisect/good-<hash>
to undo an erroneous git bisect good
.
Is this correct, or have I missed something?
And, can an analogous manipulation be done for an erroneous git bisect bad
?
Yes, those refs are what
git bisect
uses to know its current state. As such, it is possible to undo an erroneousgit bisect good
by adjusting the refs usinggit update-ref
.However, this has two catches:
Good and bad commits are marked differently by
git bisect
:All commits that are marked as good get a
refs/bisect/good-<commit id>
ref. As such, this can be undone with a correspondingHowever,
git bisect
only keeps track of a single bad commit, so you are required to reset the refrefs/bisect/bad
to a known bad commit withYou will likely need to take a look at the bisect log (under
.git/BISECT_LOG
or viagit bisect log
) to find out to which commit to reset therefs/bisect/bad
ref.In addition to the refs,
git bisect
keeps track of all its actions in a log located at.git/BISECT_LOG
. While this log is irrelevant for normal operation, fiddling with the refs yourself will lead to a nonsensical log. Of course, you may either ignore that or fix the log accordingly, but that would not be better than the solution that you have linked.So, yes, this can be done, but there is a price to pay. All in all, saving the log, fixing it, and replaying it seems to be the better alternative.