Is a more targeted recovery from git bisect errors possible?

I know that you can fix a git bisect session through git bisect log and git bisect replay , as described in the answers to this question .

However, when I ruined the bisect session, this is probably just one wrong decision, and I would like to be able to fix it directly (i.e., not interrupt it all).

For example, I can imagine that one could just do rm .git/refs/bisect/good-<hash> to undo the erroneous git bisect good .

Is this correct, or am I missing something?
And, is it possible to do a similar manipulation for the erroneous git bisect bad ?

+6
source share
1 answer

Yes, these links are what git bisect uses to find out its current state. This way you can undo the erroneous git bisect good by editing the ref with git update-ref .

However, this has two catches:

  • Good and bad commits are marked differently by git bisect :

    • All commits marked as good get refs/bisect/good-<commit id> ref. Thus, this can be undone with the appropriate

       git update-ref -d refs/bisect/good-<commit id> 
    • However, git bisect only tracks one bad commit, so you need to reset ref refs/bisect/bad to assign a known error with

       git update-ref refs/bisect/bad <really bad commit id> 

      You will probably need to look at the bisect log (in the .git/BISECT_LOG or through git bisect log ) to find out which commit the refs/bisect/bad link is bound to reset.

  • In addition to refs, git bisect tracks all its activities in a log located in .git/BISECT_LOG . Although this log is not related to normal operation, driving with refs will result in a meaningless log. Of course, you can either ignore this or fix the log accordingly, but it will not be better than the solution that you linked.

So yes, it can be done, but there is a price to pay. In general, saving the magazine, fixing it, and replaying it seems to be the best alternative.

+5
source

Source: https://habr.com/ru/post/988089/


All Articles