How do I stop git bisect?
Asked Answered
A

3

134

I tried git bisect a while ago and it helped me well, but apparently I didn't stop it. When I do git status I still get:

You are currently bisecting.
(use "git bisect reset" to get back to the original branch)

I don't really want to reset to anywhere, I just want to stop bisecting. It's really just a matter of getting rid of this message.

Ataman answered 18/4, 2014 at 14:43 Comment(0)
B
180

git bisect reset is how you stop bisecting. By default it will reset the HEAD to where it was before you started, although you can also use git bisect reset <commit> to go to that one instead.

If you just want to stop bisecting without changing the commit, from the documentation, git bisect reset HEAD would do what you want.

Bisect reset

After a bisect session, to clean up the bisection state and return to the original HEAD (i.e., to quit bisecting), issue the following command:

$ git bisect reset

By default, this will return your tree to the commit that was checked out before git bisect start. (A new git bisect start will also do that, as it cleans up the old bisection state.)

With an optional argument, you can return to a different commit instead:

$ git bisect reset <commit>

For example, git bisect reset HEAD will leave you on the current bisection commit and avoid switching commits at all, while git bisect reset bisect/bad will check out the first bad revision.

Source: http://git-scm.com/docs/git-bisect

Bruni answered 18/4, 2014 at 14:49 Comment(3)
Thanks, it worked. I'm not sure if 'git bisect reset HEAD' also has this, but when I did 'git bisect reset <current commit>' I was in detached head, so I had to re-checkout my branch.Ataman
So when i made a commit and pushed this commit, during a bisect. What do i have to do, to end bisecting and stay on my new commit (HEAD) ?Jutta
@Goblins git bisect reset HEADBecky
W
8

If git bisect reset does not work for you, just remove the bisect file:

$ rm -v .git/BISECT_*
removed '.git/BISECT_ANCESTORS_OK'
removed '.git/BISECT_LOG'
removed '.git/BISECT_NAMES'
removed '.git/BISECT_START'
removed '.git/BISECT_TERMS'
Wakeful answered 8/4, 2022 at 16:49 Comment(0)
R
0

Shijing Lv's answer mentions:

If git bisect reset does not work for you, just remove the bisect file: ...

But that should now be supported natively, since Git 2.44 (Q1 2024), "git bisect reset"(man) has been taught to clean up state files and refs, even when BISECT_START file is gone.

See commit daaa03e (07 Dec 2023) by Jeff King (peff).
(Merged by Junio C Hamano -- gitster -- in commit 67dfb89, 20 Dec 2023)

bisect: always clean on reset

Reported-by: Janik Haag
Signed-off-by: Jeff King

Usually "bisect reset" cleans up any refs/bisect/ refs, along with meta-files like .git/BISECT_LOG.
But it only does so after deciding that a bisection is active, which it does by reading BISECT_START.
That is usually fine, but it is possible to get into a confusing state if the BISECT_START file is gone, but other cruft is left (this might be due to a bug, or a system crash, etc).

And since "bisect reset" refuses to do anything in this state, the user has no easy way to clean up the leftover cruft.
While another "bisect start" would clear the state, in the interim it can be annoying, as other tools (like our bash prompt code) think we are bisecting, and for-each-ref output may be polluted with refs/bisect/ entries.

Further adding to the confusion is that running "bisect reset $some_ref" skips the BISECT_START check.
So it never realizes that there is no bisection active and does the cleanup anyway!

So let's just make sure we always do the cleanup, whether we looked at BISECT_START or not.
If the user does not give us a commit to reset to, we will still say "We are not bisecting" and skip the call to "git checkout".

No more "You are currently bisecting" after a git bisect reset.

Roche answered 26/12, 2023 at 20:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.